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. double angle_error = err * 0.001; // 转换为实际的角度误差
  14.  
  15. Point target, hide_sites[n];
  16. scanf("%d %d", &target.x, &target.y);
  17.  
  18. for (int i = 0; i < n; ++i) {
  19. scanf("%d %d", &hide_sites[i].x, &hide_sites[i].y);
  20. }
  21.  
  22. int min_head_error = 99999;
  23. int head_index = -1;
  24. int min_torso_error = 99999;
  25. int torso_index1 = -1, torso_index2 = -1;
  26.  
  27. for (int i = 0; i < n; ++i) {
  28. int distance_square = (hide_sites[i].x - target.x) * (hide_sites[i].x - target.x) +
  29. (hide_sites[i].y - target.y) * (hide_sites[i].y - target.y);
  30. double distance = sqrt(distance_square); // 距离
  31. double error = distance * angle_error; // 转换为角度误差
  32.  
  33. if (error <= min_head_error) {
  34. min_head_error = error;
  35. head_index = i;
  36. }
  37.  
  38. if (error <= min_torso_error) {
  39. min_torso_error = error;
  40. torso_index2 = torso_index1;
  41. torso_index1 = i;
  42. }
  43. }
  44.  
  45. int target_width = 0;
  46. if (min_head_error <= 1000) {
  47. target_width = 15;
  48. } else if (min_torso_error <= 2000) {
  49. target_width = 35;
  50. }
  51.  
  52. if (target_width > 0) {
  53. printf("%d", head_index);
  54. if (target_width == 35) {
  55. printf(" %d", torso_index1);
  56. }
  57. printf("\n");
  58. } else {
  59. printf("abort\n");
  60. }
  61.  
  62. return 0;
  63. }
  64.  
Success #stdin #stdout 0.01s 5464KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
1