概要
Thorさんをゴールまで導く。
移動する方向を8方向で指定する。
N: 北
W: 西
S: 南
E: 東
NE: 北東
NW: 北西
SE: 南東
SW: 南西
コツ
スタート時点の座標を計算し、移動の都度、その情報を更新する。
回答例
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
class Player
{
static void Main(String[] args)
{
string[] inputs;
inputs = Console.ReadLine().Split(' ');
int LX = int.Parse(inputs[0]); // the X position of the light of power
int LY = int.Parse(inputs[1]); // the Y position of the light of power
int TX = int.Parse(inputs[2]); // Thor's starting X position
int TY = int.Parse(inputs[3]); // Thor's starting Y position
int X = LX-TX;
int Y = LY-TY;
// game loop
while (true)
{
int E = int.Parse(Console.ReadLine()); // The level of Thor's remaining energy, representing the number of moves he can still make.
Console.Error.WriteLine("TX:"+TX+" TY:"+ TY+" LX:"+LX +" LY:"+LY +" X:"+X+" Y:"+Y);
if(X == Y){
Console.WriteLine("SE");
X--;
Y--;
}else if(X>0 && Y>=0){
Console.WriteLine("E");
X--;
}else if(X==0 && Y<0){
Console.WriteLine("N");
Y++;
}else if(X==0 && Y>0){
Console.WriteLine("S");
Y++;
}else if(X<0 && Math.Abs(X) != Y){
Console.WriteLine("W");
X++;
}else if(Math.Abs(X) == Y){
Console.WriteLine("SW");
X++;
Y--;
}
}
}
}