Guest User

Untitled

a guest
Oct 22nd, 2019
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. table = ['']
  3. for i in range(n-1):
  4. table.append(input().split(' '))
  5. a = input()
  6. a, b = a.split(' ')
  7. a = int(a)
  8. b = int(b)
  9. cost = int(table[b][a])
  10. res = a
  11. for i in range(1, n):
  12. if i != a and i != b:
  13. if int(table[i][a]) + int(table[i][b]) < cost:
  14. res = i
  15. cost = int(table[i][a]) + int(table[i][b])
  16. print(res)
RAW Paste Data