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. Point target, hide_sites[n];
  14. scanf("%d %d", &target.x, &target.y);
  15.  
  16. for (int i = 0; i < n; ++i) {
  17. scanf("%d %d", &hide_sites[i].x, &hide_sites[i].y);
  18. }
  19.  
  20. int min_head_error = 999999999;
  21. int head_index = -1;
  22. int min_torso_error = 999999999;
  23. int torso_index1 = -1, torso_index2 = -1;
  24.  
  25. for (int i = 0; i < n; ++i) {
  26. int distance_square = (hide_sites[i].x - target.x) * (hide_sites[i].x - target.x) +
  27. (hide_sites[i].y - target.y) * (hide_sites[i].y - target.y);
  28.  
  29. int target_width = 0;
  30. if (distance_square <= 1000 * 1000) { // 1000厘米转换为1米的平方
  31. target_width = 15;
  32. } else if (distance_square <= 2000 * 2000) { // 2000厘米转换为2米的平方
  33. target_width = 35;
  34. }
  35.  
  36. int error_rate = 0;
  37. if (target_width == 15) {
  38. error_rate = (target_width * 100 * 100) / distance_square; // 转换为厘米的平方
  39. } else if (target_width == 35) {
  40. error_rate = (target_width * 100 * 100) / distance_square; // 转换为厘米的平方
  41. }
  42.  
  43. if (error_rate > err) {
  44. printf("abort\n");
  45. return 0;
  46. }
  47.  
  48. if (target_width == 15 && error_rate <= err && distance_square < min_head_error) {
  49. min_head_error = distance_square;
  50. head_index = i;
  51. } else if (target_width == 35 && error_rate <= err && distance_square < min_torso_error) {
  52. min_torso_error = distance_square;
  53. torso_index2 = torso_index1;
  54. torso_index1 = i;
  55. }
  56. }
  57.  
  58. if (head_index != -1) {
  59. printf("%d\n", head_index);
  60. } else if (torso_index1 != -1) {
  61. printf("%d %d\n", torso_index1, torso_index2);
  62. } else {
  63. printf("abort\n");
  64. }
  65.  
  66. return 0;
  67. }
  68.  
Success #stdin #stdout 0s 5424KB
stdin
30
1
-104 5
339 820
stdout
0