fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. int err, n, Tx, Ty;
  6. scanf("%d", &err);
  7. scanf("%d", &n);
  8. scanf("%d %d", &Tx, &Ty);
  9.  
  10. int minHeadshotErr = 100000; // Initializing with a large value
  11. int torsoCount = 0;
  12. int firstTorsoIdx = -1, secondTorsoIdx = -1;
  13.  
  14. for (int i = 0; i < n; ++i) {
  15. int xi, yi;
  16. scanf("%d %d", &xi, &yi);
  17.  
  18. int distanceSquared = (xi - Tx) * (xi - Tx) + (yi - Ty) * (yi - Ty);
  19. int mils = (int)sqrt(distanceSquared) * 10000 / 1000; // Convert distance to mils
  20.  
  21. if (mils <= err) {
  22. int headshotErr = abs(1000 - mils); // 1000 mils = 1 meter
  23. if (headshotErr < minHeadshotErr) {
  24. minHeadshotErr = headshotErr;
  25. printf("%d ", i);
  26. }
  27. } else if (mils <= 2 * err) {
  28. torsoCount++;
  29. if (firstTorsoIdx == -1) {
  30. firstTorsoIdx = i;
  31. } else {
  32. secondTorsoIdx = i;
  33. }
  34. }
  35. }
  36.  
  37. if (minHeadshotErr != 100000) {
  38. printf("\n");
  39. } else if (torsoCount >= 2) {
  40. printf("%d %d\n", firstTorsoIdx, secondTorsoIdx);
  41. } else {
  42. printf("abort\n");
  43. }
  44.  
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 5408KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
abort