fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. typedef struct {
  5. int x, y;
  6. } Point;
  7.  
  8. int main() {
  9. int err, n;
  10. scanf("%d", &err);
  11. scanf("%d", &n);
  12.  
  13. Point target, hide_sites[n];
  14. scanf("%d %d", &target.x, &target.y);
  15.  
  16. int closest_head_index = 0, closest_torso_index1 = 0, closest_torso_index2 = 0;
  17. int min_head_distance = 2000000, min_torso_distance = 2000000;
  18.  
  19. for (int i = 0; i < n; ++i) {
  20. int x, y;
  21. scanf("%d %d", &x, &y);
  22.  
  23. int distance_squared = (x - target.x) * (x - target.x) + (y - target.y) * (y - target.y);
  24. double distance_mil = sqrt(distance_squared) * 100.0 / 100000.0;
  25.  
  26. if (distance_mil <= err) {
  27. if (y <= target.y + 3500 && y >= target.y + 1500) {
  28. if (x >= target.x - 750 && x <= target.x + 750) {
  29. if (distance_mil < min_head_distance) {
  30. min_head_distance = distance_mil;
  31. closest_head_index = i;
  32. }
  33. }
  34. } else if (y <= target.y + 1500 && y >= target.y - 1500) {
  35. if (x >= target.x - 1750 && x <= target.x + 1750) {
  36. if (distance_mil < min_torso_distance) {
  37. min_torso_distance = distance_mil;
  38. closest_torso_index2 = closest_torso_index1;
  39. closest_torso_index1 = i;
  40. }
  41. }
  42. }
  43. }
  44. }
  45.  
  46. if (closest_head_index != 0) {
  47. printf("%d\n", closest_head_index);
  48. } else if (closest_torso_index1 != 0 && closest_torso_index2 != 0) {
  49. printf("%d %d\n", closest_torso_index1, closest_torso_index2);
  50. } else {
  51. printf("abort\n");
  52. }
  53.  
  54. return 0;
  55. }
  56.  
Success #stdin #stdout 0.01s 5512KB
stdin
42
19
-1536 62
-2803 -1364
189 -1937
-477 180
-1149 269
-3396 -135
-1956 -369
-2162 -1531
-2136 488
-2499 -364
-1968 1694
-1586 141
-2018 1667
-2637 1197
-1672 1503
-2039 1104
-3413 1462
-1955 -1061
-76 1155
-1132 1527
stdout
9