klonuj pobierz
  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. int headWidth = 15;
  18. int shoulderWidth = 35;
  19. for (int i = 0; i < n; ++i) {
  20. scanf("%d %d", &hideSites[i].x, &hideSites[i].y);
  21. hideSites[i].distanceToTarget = sqrt(pow((hideSites[i].x - Tx), 2) + pow((hideSites[i].y - Ty), 2));
  22. }
  23.  
  24. int headIndex = -1;
  25. int torsoIndex1 = -1;
  26. int torsoIndex2 = -1;
  27.  
  28. for (int i = 0; i < n; ++i) {
  29. if (hideSites[i].distanceToTarget <= err) {
  30. headIndex = i;
  31. break;
  32. } else if (torsoIndex1 == -1) {
  33. torsoIndex1 = i;
  34. } else if (torsoIndex2 == -1 && hideSites[i].distanceToTarget - hideSites[torsoIndex1].distanceToTarget < 2000) {
  35. torsoIndex2 = i;
  36. break;
  37. }
  38. }
  39.  
  40. if (headIndex != -1) {
  41. printf("%d\n", headIndex);
  42. } else if (torsoIndex1 != -1 && torsoIndex2 != -1) {
  43. printf("%d %d\n", torsoIndex1, torsoIndex2);
  44. } else {
  45. printf("abort\n");
  46. }
  47.  
  48. return 0;
  49. }
  50.  
Sukces #stdin #stdout 0.01s 5436KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
0 1