fork download
  1. def distance(x1, y1, x2, y2):
  2. return ((x2 - x1)**2 + (y2 - y1)**2)**0.5
  3.  
  4. def stability(x1, y1, x2, y2, x3, y3):
  5. dist12 = distance(x1, y1, x2, y2)
  6. dist13 = distance(x1, y1, x3, y3)
  7. dist23 = distance(x2, y2, x3, y3)
  8. return max(dist12, dist13, dist23) - min(dist12, dist13, dist23)
  9.  
  10. def get_triumvirates(n, coordinates):
  11. triumvirates = []
  12. for i in range(0, n, 3):
  13. triumvirates.append([i, i + 1, i + 2])
  14. return triumvirates
  15.  
  16. def get_score(n, coordinates):
  17. triumvirates = get_triumvirates(n, coordinates)
  18. score = 0
  19. for t in triumvirates:
  20. x1, y1 = coordinates[t[0]]
  21. x2, y2 = coordinates[t[1]]
  22. x3, y3 = coordinates[t[2]]
  23. score += stability(x1, y1, x2, y2, x3, y3)
  24. return score
  25.  
  26. def main():
  27. n = int(input())
  28. coordinates = []
  29. for _ in range(n):
  30. x, y = map(int, input().split())
  31. coordinates.append((x, y))
  32.  
  33. triumvirates = get_triumvirates(n, coordinates)
  34. for t in triumvirates:
  35. print(*t)
  36.  
  37. if __name__ == "__main__":
  38. main()
Success #stdin #stdout 0.04s 9776KB
stdin
9
26 28
22 1
4 26
6 28
21 15
14 14
3 2
20 22
21 10
stdout
0 1 2
3 4 5
6 7 8