Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- 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();
- int OffsetX = 0;
- int OffsetY = 0;
- // game loop
- while (1)
- {
- int remainingTurns; // The remaining amount of turns Thor can move. Do not remove this line.
- cin >> remainingTurns; cin.ignore();
- OffsetX = abs(lightX - initialTX);
- OffsetY = abs(lightY - initialTY);
- //NE NO SE SO
- if (OffsetX == OffsetY)
- {
- if (lightX > initialTX)
- {
- if (lightY < initialTY)
- {
- cout << "NE" << endl;
- }
- else
- {
- cout << "SE" << endl;
- }
- }
- else
- {
- if (lightY < initialTY)
- {
- cout << "NW" << endl;
- }
- else
- {
- cout << "SW" << endl;
- }
- }
- }
- if (OffsetX < OffsetY)
- {
- if (OffsetX == 0)
- {
- if (lightY < initialTY)
- {
- cout << "N" << endl;
- }
- else
- {
- cout << "S" << endl;
- }
- }
- else
- {
- if (lightY < initialTY) //NE NO
- {
- if (lightX < initialTX)
- {
- cout << "NO" << endl;
- }
- else
- {
- cout << "NE" << endl;
- }
- }
- else //SE SO
- {
- if (lightX < initialTX)
- {
- cout << "SO" << endl;
- }
- else
- {
- cout << "SE" << endl;
- }
- }
- }
- }
- else //OffsetY < OffsetX
- {
- if (OffsetY == 0)
- {
- if (lightX < initialTX)
- {
- cout << "W" << endl;
- }
- else
- {
- cout << "E" << endl;
- }
- }
- else //OffsetY < OffsetX but not 0
- {
- if (lightX < initialTX)
- {
- if (lightY < initialTY)
- {
- cout << "NO" << endl;
- }
- else
- {
- cout << "SO" << endl;
- }
- }
- else
- {
- if (lightY < initialTY)
- {
- cout << "NE" << endl;
- }
- else
- {
- cout << "SE" << endl;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement