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 readonly Dictionary<int, string> dirs = new Dictionary<int,string> {
- [( 0+1) | (( 1+1) << 16)] = "N",
- [(-1+1) | (( 1+1) << 16)] = "NE",
- [(-1+1) | (( 0+1) << 16)] = "E",
- [(-1+1) | ((-1+1) << 16)] = "SE",
- [( 0+1) | ((-1+1) << 16)] = "S",
- [( 1+1) | ((-1+1) << 16)] = "SW",
- [( 1+1) | (( 0+1) << 16)] = "W",
- [( 1+1) | (( 1+1) << 16)] = "NW",
- };
- public static int Clamp (int value, int min, int max) {
- return (value < min) ? min : (value > max) ? max : value;
- }
- 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
- int thorX = initialTX;
- int thorY = initialTY;
- // game loop
- while (true) {
- int remainingTurns = int.Parse (Console.ReadLine ()); // The remaining amount of turns Thor can move. Do not remove this line.
- // Write an action using Console.WriteLine()
- // To debug: Console.Error.WriteLine("Debug messages...");
- int diffX = Clamp (thorX - lightX, -1, 1);
- int diffY = Clamp (thorY - lightY, -1, 1);
- thorX += diffX;
- thorY += diffY;
- Console.Error.WriteLine ("({0}, {1})", diffX, diffY);
- Console.WriteLine (dirs [(diffX+1) | ((diffY+1) << 16)]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement