Tamflexの貯蔵庫

やる気のない備忘録

codingame - Indiana - Level 1

やるだけ

int main()
{
  int W; // number of columns.
  int H; // number of rows.
  cin >> W >> H; cin.ignore();
  vector<vector<int>> T(W,vector<int>(H,0));
  REP(i,H)REP(j,W) cin >> T[i][j];
  int EX; // the coordinate along the X axis of the exit (not useful for this first mission, but must be read).
  cin >> EX; cin.ignore();
  // game loop
  while (1)
  {
    int x, y;
    string pos;
    cin >> x >> y >> pos; cin.ignore();
    int k = T[y][x];
    if(pos == "TOP")
    {
      if(k==1||k==3||k==7||k==9) y++;
      else if(k==4||k==10) x--;
      else if(k==5||k==11) x++;
    }
    else if(pos == "RIGHT")
    {
      if(k==1||k==4||k==7||k==8||k==12) y++;
      else if(k==2||k==6) x--;
    }
    else if(pos == "LEFT")
    {
      if(k==1||k==5||k==8||k==9||k==13) y++;
      else if(k==2||k==6) x++;
    }
    cout << x << " " << y << endl;
  }
}