Codingame『The Paranoid Android』

f:id:pongeponge:20150923070946j:plain
 自身の体を張って仲間の進行を妨害する、設計者の顔が見てみたいロボをゴールへ導く。
右移動左移動を直接指定できれば簡単なのに…と思わなくもない。
情報を仔細に得てるのに、有効に使った感じゼロ!


Test case 07 のリプレイ画面はここから





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.
 **/
class Player
{
    static void Main(string[] args)
    {
        string[] inputs;
        inputs = Console.ReadLine().Split(' ');
        int nbFloors = int.Parse(inputs[0]); // number of floors
        int width = int.Parse(inputs[1]); // width of the area
        int nbRounds = int.Parse(inputs[2]); // maximum number of rounds
        int exitFloor = int.Parse(inputs[3]); // floor on which the exit is found
        int exitPos = int.Parse(inputs[4]); // position of the exit on its floor
        int nbTotalClones = int.Parse(inputs[5]); // number of generated clones
        int nbAdditionalElevators = int.Parse(inputs[6]); // ignore (always zero)
        int nbElevators = int.Parse(inputs[7]); // number of elevators
        
        Console.Error.WriteLine("Number of floors:{0}", nbFloors);
        Console.Error.WriteLine("Width:{0}", width);
        Console.Error.WriteLine("Maximum number of rounds:{0}", nbRounds);
        Console.Error.WriteLine("Exit floor:{0}", exitFloor);
        Console.Error.WriteLine("Position of exit:{0}", exitPos);
        Console.Error.WriteLine("Number of generated clones:{0}", nbTotalClones);
        Console.Error.WriteLine("Number of elevators:{0}", nbElevators);

        int[] root = new int[nbFloors];
        root[nbFloors-1] = exitPos;
        
        for (int i = 0; i < nbElevators; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            int elevatorFloor = int.Parse(inputs[0]); // floor on which this elevator is found
            int elevatorPos = int.Parse(inputs[1]); // position of the elevator on its floor
            Console.Error.WriteLine("Number of elevator{0} floor:{1}", i, elevatorFloor);
            Console.Error.WriteLine("Position of elevator{0}:{1}", i, elevatorPos);
            
            //エレベーターの位置を格納
            root[elevatorFloor] = elevatorPos;
        }
        
        
        // game loop
        while (true)
        {
            inputs = Console.ReadLine().Split(' ');
            int cloneFloor = int.Parse(inputs[0]); // floor of the leading clone
            int clonePos = int.Parse(inputs[1]); // position of the leading clone on its floor
            Console.Error.WriteLine("Floor of the leading clone:{0}", cloneFloor);
            Console.Error.WriteLine("position of the leading clone:{0}", clonePos);

            string direction = inputs[2]; // direction of the leading clone: LEFT or RIGHT
            Console.Error.WriteLine("direction:{0}", direction);
            // Write an action using Console.WriteLine()
            // To debug: Console.Error.WriteLine("Debug messages...");
            string state = "WAIT";

            if(cloneFloor >= 0) {
                int l = root[cloneFloor] - clonePos;
                if(l < 0 && direction == "RIGHT") state = "BLOCK";
                else if(l > 0 && direction == "LEFT") state = "BLOCK";
            }
            
            Console.WriteLine(state);//"WAIT"); // action: WAIT or BLOCK
        }
    }
}