Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4.  
  5. links = []
  6. gateway = []
  7.  
  8. n, l, e = [int(i) for i in input().split()]
  9. for i in range(l):
  10. n1, n2 = [int(j) for j in input().split()]
  11. links.append((n1,n2))
  12.  
  13. for i in range(e):
  14. ei = int(input()) # the index of a gateway node
  15. gateway.append(ei)
  16.  
  17. def find_next(pos):
  18. for gate in gateway:
  19. for i in links:
  20. if (pos, gate) == i or (gate, pos) == i:
  21. links.pop(links.index(i))
  22. return f"{pos} {gate}"
  23. return 0
  24.  
  25.  
  26. while True:
  27. si = int(input()) # The index of the node on which the Skynet agent is positioned this turn
  28.  
  29. if find_next(si) != 0:
  30. print(find_next(si))
  31. else:
  32. print("0 9")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement