fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int xA,yA, xB,yB;
  7. int count = 0;
  8. int n;
  9. cin >> xA >> yA >> xB >> yB;
  10. cin >> n;
  11. int **Arr = new int* [3];
  12. for (int i = 0; i < 3; i++)
  13. Arr[i] = new int [n];
  14.  
  15. for (int i = 0; i < n; i++) {
  16. for (int j = 0; j < 3; j++) {
  17. cin >> Arr[i][j];
  18. }
  19. }
  20.  
  21. for (int i = 0; i < n; i++) {
  22. if ((xA-Arr[i][0])*(xA-Arr[i][0])+(yA-Arr[i][1])*(yA-Arr[i][1]) <= (Arr[i][2]*Arr[i][2]) || (xB-Arr[i][0])*(xB-Arr[i][0])+(yB-Arr[i][1])*(yB-Arr[i][1]) <= (Arr[i][2]*Arr[i][2])) {
  23. count++;
  24. }
  25. }
  26.  
  27.  
  28.  
  29. cout << count;
  30.  
  31. for (int i = 0; i < 3; i++)
  32. delete [] Arr[n];
  33.  
  34. return 0;
  35. }
Runtime error #stdin #stdout #stderr 0s 4452KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc