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 abort_flag = 1;
  21.  
  22. for (int i = 0; i < n; ++i) {
  23. int distance_square = (hide_sites[i].x - target.x) * (hide_sites[i].x - target.x) +
  24. (hide_sites[i].y - target.y) * (hide_sites[i].y - target.y);
  25. int error = sqrt(distance_square);
  26.  
  27. // If any hide site falls within the allowed error, mission is not aborted
  28. if (error <= err) {
  29. abort_flag = 0;
  30. break;
  31. }
  32. }
  33.  
  34. if (abort_flag) {
  35. printf("abort\n");
  36. } else {
  37. // Mission is not aborted
  38. // Handle the mission logic here if needed
  39. }
  40.  
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5476KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
abort