fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. struct HideSite {
  5. int x, y;
  6. double distanceToTarget;
  7. };
  8.  
  9. int main() {
  10. int err, n, Tx, Ty;
  11. scanf("%d", &err);
  12. scanf("%d", &n);
  13. scanf("%d %d", &Tx, &Ty);
  14.  
  15. struct HideSite hideSites[n];
  16.  
  17. for (int i = 0; i < n; ++i) {
  18. scanf("%d %d", &hideSites[i].x, &hideSites[i].y);
  19. hideSites[i].distanceToTarget = sqrt(pow(hideSites[i].x - Tx, 2) + pow(hideSites[i].y - Ty, 2));
  20. }
  21.  
  22. int headIndex = -1;
  23. int torsoIndex1 = -1;
  24. int torsoIndex2 = -1;
  25.  
  26. for (int i = 0; i < n; ++i) {
  27. if (hideSites[i].distanceToTarget <= err) {
  28. headIndex = i;
  29. break;
  30. } else if (torsoIndex1 == -1 && hideSites[i].distanceToTarget <= 2 * err) {
  31. torsoIndex1 = i;
  32. } else if (torsoIndex2 == -1 && hideSites[i].distanceToTarget <= 2 * err) {
  33. torsoIndex2 = i;
  34. break;
  35. }
  36. }
  37.  
  38. if (headIndex != -1) {
  39. printf("%d\n", headIndex);
  40. } else if (torsoIndex1 != -1 && torsoIndex2 != -1) {
  41. printf("%d %d\n", torsoIndex1, torsoIndex2);
  42. } else {
  43. printf("abort\n");
  44. }
  45.  
  46. return 0;
  47. }
  48.  
Success #stdin #stdout 0s 5540KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
abort