Advertisement
Hezov

Bomber - #841

Nov 29th, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream cin("bomber.in");
  4. ofstream cout("bomber.out");
  5. int n , I;
  6. struct bomba{
  7.     int x, y, p;
  8.     bool  explodat = false;
  9.     void citire()
  10.     {
  11.         cin>>x>>y>>p;
  12.     }
  13. }v[10001];
  14. int distP(int a, int b)
  15. {
  16.     int x = v[a].x - v[b].x;
  17.     int y = v[a].y - v[b].y;
  18.     return (x*x + y*y);
  19. }
  20. void explode(int poz)
  21. {
  22.     v[poz].explodat = true;
  23.     for(int i = 1;i<=n;i++)
  24.     {
  25.         if(!v[i].explodat)
  26.         {
  27.             if(distP(poz,i) <= v[poz].p*v[poz].p)
  28.                 explode(i);
  29.         }
  30.     }
  31. }
  32. int main()
  33. {
  34.     cin>>n>>I;
  35.     for(int i = 1;i<=n;i++)
  36.         v[i].citire();
  37.     explode(I);
  38.     int cnt = 0;
  39.     for(int i = 1;i<=n;i++)
  40.         if(!v[i].explodat)
  41.             cnt++;
  42.     cout << cnt;
  43.     return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement