Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- var inputs = readline().split(' ');
- var N = parseInt(inputs[0]); // the total number of nodes in the level, including the gateways
- var L = parseInt(inputs[1]); // the number of links
- var E = parseInt(inputs[2]); // the number of exit gateways
- var links = [];
- var gates = [];
- for (var i = 0; i < L; i++) {
- var inputs = readline().split(' ');
- var N1 = parseInt(inputs[0]); // N1 and N2 defines a link between these nodes
- var N2 = parseInt(inputs[1]);
- links.push([N1, N2]);
- }
- for (var i = 0; i < E; i++) {
- var EI = parseInt(readline()); // the index of a gateway node
- printErr(EI);
- gates.push(EI);
- }
- // game loop
- while (true) {
- var SI = parseInt(readline()); // The index of the node on which the Skynet agent is positioned this turn
- // Write an action using print()
- // To debug: printErr('Debug messages...');
- var p=false;
- for (var i=0; i<links.length; i++)
- {
- for (var j=0; j<gates.length; j++)
- {
- if ((links[i][0]==SI && links[i][1]==gates[j])||(links[i][0]==gates[j] && links[i][1]==SI))
- {
- print(links[i][0]+" "+links[i][1]);
- links.splice(i,1);
- p=true;
- }
- }
- }
- if (!p)
- {
- for (var i=0; i<links.length; i++)
- {
- if (!p&&(links[i][0]==SI || links[i][1]==SI))
- {
- print(links[i][0]+" "+links[i][1]);
- links.splice(i,1);
- p=true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment