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. if (n == 1) {
  14. printf("abort\n");
  15. return 0;
  16. }
  17.  
  18. Point target, hide_sites[n];
  19. scanf("%d %d", &target.x, &target.y);
  20.  
  21. for (int i = 0; i < n; ++i) {
  22. scanf("%d %d", &hide_sites[i].x, &hide_sites[i].y);
  23. }
  24.  
  25. int min_head_error = 999999999;
  26. int head_index = -1;
  27. int min_torso_error = 999999999;
  28. int torso_index1 = -1, torso_index2 = -1;
  29.  
  30. for (int i = 0; i < n; ++i) {
  31. int distance_square = (hide_sites[i].x - target.x) * (hide_sites[i].x - target.x) +
  32. (hide_sites[i].y - target.y) * (hide_sites[i].y - target.y);
  33.  
  34. int target_width = 0;
  35. if (distance_square <= 1000 * 1000) { // 1000厘米转换为1米的平方
  36. target_width = 15;
  37. } else if (distance_square <= 2000 * 2000) { // 2000厘米转换为2米的平方
  38. target_width = 35;
  39. }
  40.  
  41. int error_rate = 0;
  42. if (target_width == 15) {
  43. error_rate = (target_width * 100 * 100) / distance_square; // 转换为厘米的平方
  44. } else if (target_width == 35) {
  45. error_rate = (target_width * 100 * 100) / distance_square; // 转换为厘米的平方
  46. }
  47.  
  48. if (error_rate > err) {
  49. printf("abort\n");
  50. return 0;
  51. }
  52.  
  53. if (target_width == 15 && error_rate <= err && distance_square < min_head_error) {
  54. min_head_error = distance_square;
  55. head_index = i;
  56. } else if (target_width == 35 && error_rate <= err && distance_square < min_torso_error) {
  57. min_torso_error = distance_square;
  58. torso_index2 = torso_index1;
  59. torso_index1 = i;
  60. }
  61. }
  62.  
  63. if (head_index != -1) {
  64. printf("%d\n", head_index);
  65. } else if (torso_index1 != -1) {
  66. printf("%d %d\n", torso_index1, torso_index2);
  67. } else {
  68. printf("abort\n");
  69. }
  70.  
  71. return 0;
  72. }
  73.  
Success #stdin #stdout 0s 5440KB
stdin
18
11
1563588 1486379
1561768 1486652
1565578 1487883
1565323 1487671
1565478 1485701
1563789 1488357
1564975 1484728
1563807 1485864
1563187 1486786
1563547 1487697
1564567 1488194
1561796 1488193
stdout
6