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, Tx, Ty;
  10. scanf("%d", &err);
  11. scanf("%d", &n);
  12. scanf("%d %d", &Tx, &Ty);
  13.  
  14. Point sites[n];
  15. for (int i = 0; i < n; ++i) {
  16. scanf("%d %d", &sites[i].x, &sites[i].y);
  17. }
  18.  
  19. int minHeadError = 1000000; // Initial large value for comparison
  20. int minTorsoError = 1000000; // Initial large value for comparison
  21. int headIndex = -1, torsoIndex1 = -1, torsoIndex2 = -1;
  22.  
  23. for (int i = 0; i < n; ++i) {
  24. int distanceSquared = (Tx - sites[i].x) * (Tx - sites[i].x) + (Ty - sites[i].y) * (Ty - sites[i].y);
  25. int error = sqrt(distanceSquared) * err / 100;
  26.  
  27. // Calculate error for head and torso
  28. int headError = error - 15; // Head width is 15 cm
  29. int torsoError = error - 35; // Torso width is 35 cm
  30.  
  31. // Check if the site hits head accurately
  32. if (headError <= 0 && error < minHeadError) {
  33. minHeadError = error;
  34. headIndex = i;
  35. }
  36.  
  37. // Check if the site hits torso accurately
  38. if (torsoError <= 0 && error < minTorsoError) {
  39. minTorsoError = error;
  40. torsoIndex2 = torsoIndex1;
  41. torsoIndex1 = i;
  42. }
  43. }
  44.  
  45. // Output the result
  46. if (headIndex != -1) {
  47. printf("%d\n", headIndex);
  48. } else if (torsoIndex1 != -1 && torsoIndex2 != -1) {
  49. printf("%d %d\n", torsoIndex1, torsoIndex2);
  50. } else {
  51. printf("Mission aborted\n");
  52. }
  53.  
  54. return 0;
  55. }
  56.  
Success #stdin #stdout 0.01s 5304KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
Mission aborted