Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fin = open('input.txt')
- n = int(fin.readline())
- cords = [[0 for y in range(0, n)]for x in range(0, n)]
- for t in range(0, n-1):
- a, b = [int(o) for o in fin.readline().split()]
- y = cords[a-1]
- y[b-1] = 1
- x = cords[b-1]
- x[a-1] = 1
- maxSum = 0
- cityIndex = 0
- for x in range(0, n - 1):
- sum = 0
- for y in cords[x]:
- sum += y
- if sum > maxSum:
- cityIndex = x
- maxSum = sum
- fout = open('output.txt', 'w')
- print(maxSum, cityIndex + 1, file=fout)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement