fork(2) download
  1. import math
  2. n = int(input())
  3. r = []
  4. res = []
  5. i = 0
  6. while n > 0:
  7. k = int(input())
  8. res.append([])
  9. while k > 0:
  10. name, x, y = input().split()
  11. x = int(x)
  12. y = int(y)
  13. distance = math.sqrt(math.pow(x, 2) + math.pow(y, 2))
  14. if len(r) > 0:
  15. for e in range(0,len(r)):
  16. if distance < r[e]:
  17. r.insert(e, distance)
  18. res[i].insert(e, "{} {} {}".format(name, x, y))
  19. break
  20. elif e == len(r)-1:
  21. r.append(distance)
  22. res[i].append("{} {} {}".format(name, x, y))
  23. elif distance > r[i]:
  24. continue
  25. else:
  26. r.append(distance)
  27. res[i].append("{} {} {}".format(name, x, y))
  28. k -= 1
  29. clear = input()
  30. n -= 1
  31. if n > 0:
  32. print()
  33. i += 1
  34. del r[:]
  35. for e in range(0,i):
  36. print("\n".join(res[e]))
  37. if e != len(res)-1:
  38. print()
Runtime error #stdin #stdout #stderr 0.04s 9540KB
stdin
2
3
A 0 0
C 5 5
B 1 -1

1 
X 1 1
stdout

	
stderr
Traceback (most recent call last):
  File "./prog.py", line 29, in <module>
EOFError: EOF when reading a line