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 min_head_index = -1, first_torso_index = -1, second_torso_index = -1;
  11. int min_head_distance = 2000 * 2000; // Maximum possible distance
  12. int min_torso_distance = 2000 * 2000;
  13.  
  14. for (int i = 0; i < n; ++i) {
  15. int xi, yi;
  16. scanf("%d %d", &xi, &yi);
  17.  
  18. int distance_squared = (xi - Tx) * (xi - Tx) + (yi - Ty) * (yi - Ty);
  19. int err_squared = (err * 100) * (err * 100);
  20.  
  21. // Calculate dispersion in mils
  22. int dispersion_squared = distance_squared / err_squared;
  23.  
  24. // Calculate target dimensions in mils
  25. int head_width_mils = (15 * 100) * (1000 / 100); // 15 cm to mils
  26. int torso_width_mils = (35 * 100) * (1000 / 100); // 35 cm to mils
  27.  
  28. // Check if the hide site allows accurate shooting
  29. if (dispersion_squared <= head_width_mils * head_width_mils) {
  30. // Accurate head shot
  31. if (dispersion_squared < min_head_distance) {
  32. min_head_distance = dispersion_squared;
  33. min_head_index = i;
  34. }
  35. } else if (dispersion_squared <= torso_width_mils * torso_width_mils) {
  36. // Accurate torso shot
  37. if (first_torso_index == -1) {
  38. first_torso_index = i;
  39. } else if (dispersion_squared < min_torso_distance) {
  40. min_torso_distance = dispersion_squared;
  41. second_torso_index = i;
  42. }
  43. }
  44. }
  45.  
  46. if (min_head_index != -1) {
  47. // Accurate head shot
  48. printf("%d", min_head_index);
  49. } else if (first_torso_index != -1 && second_torso_index != -1) {
  50. // Accurate torso shot
  51. printf("%d %d", first_torso_index, second_torso_index);
  52. } else {
  53. // No suitable hide site
  54. printf("abort");
  55. }
  56.  
  57. return 0;
  58. }
  59.  
Success #stdin #stdout 0.01s 5444KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
Standard output is empty