NikitaShigaev

Untitled

May 11th, 2020
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 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 astr {
  9.     double x, y, z;
  10.     unsigned long long ts, uuid;
  11. };
  12.  
  13. bool cmp (astr a, astr b) {
  14.     return a.ts < b.ts;
  15. }
  16.  
  17. int main()
  18. {
  19.     vector<astr> v;
  20.     set <unsigned long long> s;
  21.     unsigned long long n;
  22.     double x0, y0, z0, r;
  23.     cin >> x0 >> y0 >> z0 >> r;
  24.     cin >> n;
  25.     for (unsigned long long i = 0; i < n; ++i) {
  26.         astr tmp;
  27.         cin >> tmp.uuid >> tmp.ts >> tmp.x >> tmp.y >> tmp.z;
  28.         v.push_back(tmp);
  29.     }
  30.     sort(v.begin(), v.end(), cmp);
  31.     for (unsigned long long i = 0; i < n; ++i) {
  32.         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));
  33.         if (l < r) {
  34.             if(s.find(v[i].uuid) == s.end()) {
  35.                 cout << v[i].uuid << '\n';
  36.                 s.insert(v[i].uuid);
  37.             }
  38.         }
  39.     }
  40.     return 0;
  41. }
Add Comment
Please, Sign In to add comment