Advertisement
NikitaShigaev

Untitled

Apr 29th, 2020
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <set>
  5. using namespace std;
  6.  
  7. struct asteroid {
  8.     double x, y, z;
  9.     unsigned long long ts, uuid;
  10. };
  11.  
  12. int main()
  13. {
  14.     vector<asteroid> v;
  15.     set <unsigned long long> s;
  16.     unsigned long long n;
  17.     double x0, y0, z0, r;
  18.     cin >> x0 >> y0 >> z0 >> r;
  19.     cin >> n;
  20.     for (unsigned long long i = 0; i < n; ++i) {
  21.         asteroid a;
  22.         cin >> a.uuid >> a.ts >> a.x >> a.y >> a.z;
  23.         v.push_back(a);
  24.     }
  25.     for (unsigned long long i = 0; i < n; ++i) {
  26.         for (unsigned long long j = i + 1; j < n; ++j) {
  27.             if(v[i].ts > v[j].ts) {
  28.                 unsigned long long t = v[i].ts;
  29.                 v[i].ts = v[j].ts;
  30.                 v[j].ts = t;
  31.             }
  32.         }
  33.     }
  34.     for (unsigned long long i = 0; i < n; ++i) {
  35.         double l = sqrt((v[i].x - x0) * (v[i].x - x0) + (v[i].y - y0) * (v[i].y - y0) + (v[i].z - z0) * (v[i].z - z0));
  36.         if (l < r) {
  37.             if(s.find(v[i].uuid) == s.end()) {
  38.                 cout << v[i].uuid << '\n';
  39.                 s.insert(v[i].uuid);
  40.             }
  41.         }
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement