Kevin_Zhang

Untitled

Jan 17th, 2021
732
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define pb emplace_back
  3. #define AI(i) begin(i), end(i)
  4. using namespace std;
  5. using ll = long long;
  6. template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
  7. template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
  8. #ifdef KEV
  9. #define DE(args...) kout("[ " + string(#args) + " ] = ", args)
  10. void kout() {cerr << endl;}
  11. template<class T, class ...U> void kout (T v, U ...e) { cerr << v << ' ', kout(e...); }
  12. template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L)==R], ++L; }
  13. #else
  14. #define DE(...) 0
  15. #define debug(...) 0
  16. #endif
  17. // What I should check
  18. // 1. overflow
  19. // 2. corner cases
  20. // Enjoy the problem instead of hurrying to AC
  21. // Good luck !
  22. const int MAX_N = 300010;
  23. const double eps = 1e-5;
  24.  
  25. bool solve() {
  26.     const int N = 20;
  27.     vector<pair<double,double>> dot(N);
  28.     for (auto &[x, y] : dot)
  29.         cin >> x >> y;
  30.     double area = 0;
  31.     dot.pb(dot[0]);
  32.  
  33.     for (int i = 0;i < N;++i) {
  34.         area += dot[i].first * dot[i+1].second - dot[i].second * dot[i+1].first;
  35.     }
  36.     dot.pop_back();
  37.     if (area > 0) {
  38.         reverse(AI(dot));
  39.     }
  40.  
  41.     for (int i = 0;i < N;++i)
  42.         dot.pb(dot[i]);
  43.  
  44.     auto dis = [&](int a, int b) {
  45.         auto [x1, y1] = dot[a];
  46.         auto [x2, y2] = dot[b];
  47.         return hypot(x1-x2, y1-y2);
  48.     };
  49.     auto close = [&](double v, double u) {
  50.         return abs(u - v) < eps;
  51.     };
  52.     for (int i = 0;i < N;++i) {
  53.         if (close(dis(i, i+1), 6) && close(dis(i+1, i+2), 1))
  54.             return true;
  55.     }
  56.     return false;
  57.  
  58. }
  59. int32_t main() {
  60.     ios_base::sync_with_stdio(0), cin.tie(0);
  61.     int T;
  62.     cin >> T;
  63.     while (T--)
  64.         puts(solve() ? "right" : "left");
  65. }
  66.  
RAW Paste Data