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; // Assume abort by default
  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 (error <= err) {
  28. // If a hide site is found within the allowed error, mission can proceed
  29. abort_flag = 0;
  30. break;
  31. }
  32. }
  33.  
  34. if (abort_flag) {
  35. // No suitable hide site found, output 'abort'
  36. printf("abort\n");
  37. } else {
  38. // A suitable hide site found within the allowed error
  39. // Do nothing, mission can proceed
  40. }
  41.  
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0.01s 5444KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
abort