fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. int err, n, Tx, Ty;
  6. scanf("%d", &err);
  7. scanf("%d", &n);
  8. scanf("%d %d", &Tx, &Ty);
  9.  
  10. int closest_head_index = -1, closest_torso_index1 = -1, closest_torso_index2 = -1;
  11. int min_head_distance = 2000000, min_torso_distance = 2000000;
  12.  
  13. for (int i = 0; i < n; ++i) {
  14. int x, y;
  15. scanf("%d %d", &x, &y);
  16.  
  17. int distance_squared = (x - Tx) * (x - Tx) + (y - Ty) * (y - Ty);
  18. double distance_mil = sqrt(distance_squared) * 100.0 / 100000.0;
  19.  
  20. if (distance_mil <= err) {
  21. // Check if it's in the head or torso area
  22. if (y <= Ty + 3500 && y >= Ty + 1500) {
  23. // Check head area
  24. if (x >= Tx - 750 && x <= Tx + 750) {
  25. if (distance_mil < min_head_distance) {
  26. min_head_distance = distance_mil;
  27. closest_head_index = i;
  28. }
  29. }
  30. } else if (y <= Ty + 1500 && y >= Ty - 1500) {
  31. // Check torso area
  32. if (x >= Tx - 1750 && x <= Tx + 1750) {
  33. if (distance_mil < min_torso_distance) {
  34. min_torso_distance = distance_mil;
  35. closest_torso_index2 = closest_torso_index1;
  36. closest_torso_index1 = i;
  37. }
  38. }
  39. }
  40. }
  41. }
  42.  
  43. if (closest_head_index != -1) {
  44. // Sniper can accurately hit the target in the head
  45. printf("%d\n", closest_head_index);
  46. } else if (closest_torso_index1 != -1 && closest_torso_index2 != -1) {
  47. // Sniper can accurately hit the target in the torso with two hide sites
  48. printf("%d %d\n", closest_torso_index1, closest_torso_index2);
  49. } else {
  50. // No suitable hide site found
  51. printf("abort\n");
  52. }
  53.  
  54. return 0;
  55. }
  56.  
Success #stdin #stdout 0.01s 5436KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
0