fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. typedef struct {
  5. int x;
  6. int y;
  7. } Point;
  8.  
  9. int main() {
  10. int err, n;
  11. scanf("%d", &err);
  12. scanf("%d", &n);
  13.  
  14. int Tx, Ty;
  15. scanf("%d %d", &Tx, &Ty);
  16.  
  17. Point hideSites[n];
  18. for (int i = 0; i < n; ++i) {
  19. scanf("%d %d", &hideSites[i].x, &hideSites[i].y);
  20. }
  21.  
  22. int minHeadError = 2000;
  23. int minTorsoError = 2000;
  24. int headIndex = -1;
  25. int torsoIndex1 = -1;
  26. int torsoIndex2 = -1;
  27.  
  28. for (int i = 0; i < n; ++i) {
  29. int distanceSquared = (Tx - hideSites[i].x) * (Tx - hideSites[i].x) + (Ty - hideSites[i].y) * (Ty - hideSites[i].y);
  30. int error = sqrt(distanceSquared) * err;
  31.  
  32. if (error <= 15) {
  33. // Inside head area
  34. if (error < minHeadError) {
  35. minHeadError = error;
  36. headIndex = i;
  37. }
  38. } else if (error <= 35) {
  39. // Inside torso area
  40. if (error < minTorsoError) {
  41. minTorsoError = error;
  42. torsoIndex2 = torsoIndex1;
  43. torsoIndex1 = i;
  44. }
  45. }
  46. }
  47.  
  48. if (headIndex != -1) {
  49. printf("%d", headIndex);
  50. } else if (torsoIndex1 != -1 && torsoIndex2 != -1) {
  51. printf("%d %d", torsoIndex1, torsoIndex2);
  52. } else {
  53. printf("abort");
  54. }
  55.  
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0s 5548KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
abort