Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- * ---
- * Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
- **/
- int main()
- {
- int lightX; // the X position of the light of power
- int lightY; // the Y position of the light of power
- int initialTX; // Thor's starting X position
- int initialTY; // Thor's starting Y position
- cin >> lightX >> lightY >> initialTX >> initialTY; cin.ignore();
- // game loop
- while (1) {
- int remainingTurns;
- cin >> remainingTurns; cin.ignore();
- // Write an action using cout. DON'T FORGET THE "<< endl"
- // To debug: cerr << "Debug messages..." << endl;
- int thorX,thorY;
- int directionX=0;
- int directionY=0;
- thorX=initialTX;
- thorY=initialTY;
- if(thorX>lightX)
- {
- directionX='W';
- thorX=thorX-1;
- }
- else if(thorY<lightX)
- {directionX='E';
- thorX=thorX+1;
- }
- if(thorY>lightY)
- {
- directionY='N';
- thorY=thorY-1;}
- else if(thorY<lightY)
- {directionY='E';
- thorY=thorY+1;
- }
- cout <<"(directionX,directionY)"<< endl; // A single line providing the move to be made: N NE E SE S SW W or NW
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement