Advertisement
NikitaShigaev

Untitled

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