Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- links = []
- gateway = []
- n, l, e = [int(i) for i in input().split()]
- for i in range(l):
- n1, n2 = [int(j) for j in input().split()]
- links.append((n1,n2))
- for i in range(e):
- ei = int(input()) # the index of a gateway node
- gateway.append(ei)
- def find_next(pos):
- for gate in gateway:
- for i in links:
- if (pos, gate) == i or (gate, pos) == i:
- links.pop(links.index(i))
- return f"{pos} {gate}"
- return 0
- while True:
- si = int(input()) # The index of the node on which the Skynet agent is positioned this turn
- if find_next(si) != 0:
- print(find_next(si))
- else:
- print("0 9")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement