Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. n = int(input())
  2. p = []
  3. # the number of relationships of influence
  4. for i in range(n):
  5.     # x: a relationship of influence between two people (x influences y)
  6.     x, y = [int(j) for j in input().split()]
  7.     p.append((x,y))
  8.            
  9. length = 0
  10. print(p, file=sys.stderr)
  11. for x,y in p:
  12.     p1 = list(p)
  13.     p1.remove((x,y))
  14.     j = [x,y]
  15.     for obj in p1:
  16.  
  17.         if j[0] == obj[-1]:
  18.             j.insert(0,obj[0])
  19.         elif j[-1] == obj[0]:
  20.             j.append(obj[-1])
  21.     print(j, file=sys.stderr)
  22.     if len(j) > length:
  23.         length = len(j)
  24.    
  25.    
  26. print(length)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement