@@ -0,0 +1,2796 @@
+import java.util.*;%0A%0A/**%0A * Auto-generated code below aims at helping you parse%0A * the standard input according to the problem statement.%0A **/%0Aclass Player %7B%0A%0A    private static Set%3CInteger%3E visited = new HashSet%3CInteger%3E();%0A    private static Set%3CInteger%3E gateways = new HashSet%3CInteger%3E();%0A    static int N = 0;%0A    static int%5B%5D%5B%5D GM;%0A    static String lastCommand = null;%0A    public static void main(String args%5B%5D) %7B%0A        Scanner in = new Scanner(System.in);%0A        N = in.nextInt(); // the total number of nodes in the level, including the gateways%0A        GM = new int%5BN%5D%5BN%5D;%0A%0A%0A        int L = in.nextInt(); // the number of links%0A        int E = in.nextInt(); // the number of exit gateways%0A%0A%0A        for (int i = 0; i %3C L; i++) %7B%0A            int N1 = in.nextInt(); // N1 and N2 defines a link between these nodes%0A            int N2 = in.nextInt();%0A            GM%5BN1%5D%5BN2%5D = 1;%0A            GM%5BN2%5D%5BN1%5D = 1;%0A        %7D%0A%0A        for (int i = 0; i %3C E; i++) %7B%0A            int EI = in.nextInt(); // the index of a gateway node%0A            gateways.add(EI);%0A        %7D%0A%0A        System.err.println(gateways.iterator().next());%0A        // game loop%0A        while (true) %7B%0A            int SI = in.nextInt(); // The index of the node on which the Skynet agent is positioned this turn%0A%0A            // Write an action using System.out.println()%0A%0A%0A            // Example: 0 1 are the indices of the nodes you wish to sever the link between%0A            Map%3CInteger, Queue%3CInteger%3E%3E queueNextLevel = new HashMap%3CInteger, Queue%3CInteger%3E%3E();%0A            queueNextLevel.put(SI, getChildren(SI));%0A%0A            findFirstExit(queueNextLevel);%0A            System.out.println(lastCommand);%0A        %7D%0A    %7D%0A%0A    private static Queue%3CInteger%3E getChildren(int x)%7B%0A        Queue%3CInteger%3E set = new LinkedList%3CInteger%3E();%0A        for (int i = 0; i %3C N; i++) %7B%0A            if (GM%5Bx%5D%5Bi%5D == 1) %7B%0A                set.add(i);%0A            %7D%0A        %7D%0A        return set;%0A    %7D%0A%0A    public static String findFirstExit(Map%3CInteger, Queue%3CInteger%3E%3E level)%7B%0A        Map%3CInteger, Queue%3CInteger%3E%3E nextLevel = new HashMap%3CInteger, Queue%3CInteger%3E%3E();%0A        for (Integer currentRoot: level.keySet()  ) %7B%0A            Queue%3CInteger%3E children = level.get(currentRoot);%0A            visited.add(currentRoot);%0A            while (!children.isEmpty())%7B%0A                int currentChildNode = children.remove();%0A                if (gateways.contains(currentChildNode))%7B%0A                    lastCommand = %22%22+currentRoot+%22 %22+currentChildNode;%0A                    return %22%22+currentRoot+%22 %22+currentChildNode;%0A                %7D%0A                nextLevel.put(currentChildNode, getChildren(currentChildNode));%0A            %7D%0A        %7D%0A        if (!nextLevel.isEmpty()) %7B%0A            findFirstExit(nextLevel);%0A        %7D%0A        return null;%0A    %7D%0A%7D

add sky net solution in Java