fork(1) download
  1. def center_distance(x, y):
  2. return round((int(x) ** 2 + int(y) ** 2) ** 0.5, 4)
  3.  
  4.  
  5. def sorting(scores):
  6. scores_2 = sorted(scores)
  7.  
  8. counter_not_order = 0
  9. counter_order = 0
  10. order = []
  11.  
  12. while counter_order < len(scores):
  13. if scores[counter_not_order] != scores_2[counter_order]:
  14. counter_not_order += 1
  15. else:
  16. order.append(counter_not_order)
  17. counter_order += 1
  18. counter_not_order = 0
  19.  
  20. return order
  21.  
  22.  
  23. test = int(input())
  24.  
  25. for t in range(0, test):
  26.  
  27. names_list = []
  28. x_list = []
  29. y_list = []
  30. scores_list = []
  31.  
  32. amount_points = int(input())
  33.  
  34. for tt in range(0, amount_points):
  35. name, x, y = list(map(str, input().split()))
  36. names_list.append(name)
  37.  
  38. x_list.append(int(x))
  39. y_list.append(int(y))
  40. scores_list.append(center_distance(x, y))
  41.  
  42. orders = sorting(scores_list)
  43.  
  44. for i in orders:
  45. print(f'{names_list[i]} {x_list[i]} {y_list[i]}')
  46.  
Runtime error #stdin #stdout #stderr 0.12s 23648KB
stdin
2
3
A 0 0
C 5 5
B 1 -1

1 
X 1 1
stdout
A 0 0
B 1 -1
C 5 5
stderr
Traceback (most recent call last):
  File "./prog.py", line 32, in <module>
ValueError: invalid literal for int() with base 10: ''