Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.IO;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- /**
- * 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.
- **/
- class Player
- {
- static void Main(string[] args)
- {
- string[] inputs = Console.ReadLine().Split(' ');
- int lightX = int.Parse(inputs[0]); // the X position of the light of power
- int lightY = int.Parse(inputs[1]); // the Y position of the light of power
- int initialTX = int.Parse(inputs[2]); // Thor's starting X position
- int initialTY = int.Parse(inputs[3]); // Thor's starting Y position
- // game loop
- while (true)
- {
- Action<string> move = (string dir) => Console.WriteLine(dir);
- Action<int, string> moveN = (int n, string dir) =>
- {
- for (int i = 0; i < n; i++)
- move(dir);
- };
- Action<int, string, int, string> moveKek = (int hypoten, string tt, int stright, string td) =>
- {
- moveN(stright, td);
- moveN(hypoten, tt);
- };
- int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.
- Console.Error.WriteLine(remainingTurns.ToString());
- // Write an action using Console.WriteLine()
- // To debug: Console.Error.WriteLine("Debug messages...");
- // A single line providing the move to be made: N NE E SE S SW W or NW
- var deltaX = lightX - initialTX;
- var deltaY = lightY - initialTY;
- var absX = (int) Math.Abs(deltaX);
- var absY = (int) Math.Abs(deltaY);
- if (deltaX == 0 && deltaY > 0)
- move("S");
- if (deltaX == 0 && deltaY < 0)
- move("N");
- if (deltaY == 0 && deltaX > 0)
- move("E");
- if (deltaY == 0 && deltaX < 0)
- move("W");
- var switcher = CheckSwitcher(deltaX, deltaY);
- var straight = (int) Math.Abs(absX - absY);
- var hypotenX = (int) Math.Round(absX * Math.Sqrt(2));
- var hypotenY = (int) Math.Round(absY * Math.Sqrt(2));
- Console.Error.WriteLine("Debug messages " + hypotenX);
- switch(switcher)
- {
- case 1:
- moveKek(hypotenX, "SE", straight, "S");
- break;
- case 2:
- moveKek(hypotenX, "SW", straight, "S");
- break;
- case 3:
- moveKek(hypotenY, "SE", straight, "E");
- break;
- case 4:
- moveKek(hypotenY, "NW", straight, "W");
- break;
- case 5:
- moveKek(hypotenX, "NW", straight, "N");
- break;
- case 6:
- moveKek(hypotenX, "NE", straight, "N");
- break;
- case 7:
- moveKek(hypotenY, "NE", straight, "E");
- break;
- case 8:
- moveKek(hypotenX, "SW", straight, "W");
- break;
- }
- //Console.WriteLine("SE");
- }
- }
- static int CheckSwitcher(int deltaX, int deltaY)
- {
- var absX = Math.Abs(deltaX);
- var absY = Math.Abs(deltaY);
- if (deltaX < 0 && deltaY > 0)
- return (absY > absX) ? 1 : 8;
- if (deltaX > 0 && deltaY > 0)
- return (absY > absX) ? 2 : 3;
- if (deltaX > 0 && deltaY < 0)
- return (absY > absX) ? 5 : 4;
- if (deltaX < 0 && deltaY < 0)
- return (absY > absX) ? 6 : 4;
- return -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement