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 5544KB
stdin
40
19
-1596 -795
-1715 927
262 806
381 -2642
-3391 -708
-2136 -681
-724 -1799
-1393 927
230 -2145
-2460 -2040
-549 -1485
-2199 962
172 -1912
-3013 -636
-2307 -2330
-1162 -2664
-1459 743
-1465 -2291
176 -65
-2976 -993
stdout
abort