Alex_tz307

School-CCC Hyperloop Direct - Level 4

Oct 28th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("text.in");
  6. ofstream fout("text.out");
  7.  
  8. struct obstacle {
  9.     int x1, x2, Y;
  10.     double u1, u2;
  11. };
  12.  
  13. int main() {
  14.     int N;
  15.     fin >> N;
  16.     vector < obstacle > a(N);
  17.     for(auto& x : a) {
  18.         fin >> x.x1 >> x.x2 >> x.Y;
  19.         x.u1 = atan2(x.Y, x.x1);
  20.         x.u2 = atan2(x.Y, x.x2);
  21.     }
  22.     int T;
  23.     fin >> T;
  24.     while(T--) {
  25.         int x, y;
  26.         fin >> x >> y;
  27.         double u = atan2(y, x);
  28.         bool ok = true;
  29.         for(auto x : a)
  30.             if(!(u < min(x.u1, x.u2) || u > max(x.u1, x.u2) || (y < x.Y && x.Y > 0) || (y > x.Y && x.Y < 0)))
  31.                 ok = false;
  32.         if(ok)
  33.             fout << x << ' ' << y << ' ';
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment