제출 #254109

#제출 시각아이디문제언어결과실행 시간메모리
254109MrRobot_28Zvijezda (COCI19_zvijezda)C++17
20 / 110
166 ms2316 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector <pair <int, int> > pol; int n; bool crossproduct(pair <int, int> a, pair <int, int> b, pair <int, int> c) { return (long double) (b.first - a.first) * (c.second - a.second) >= (long double)(b.second - a.second) * (c.first - a.first); } int check(pair <int, int> a, int l, int r) { int al = l, ar = r + 1; while(ar - al > 1) { int midd = (ar + al) / 2; if(crossproduct(a, pol[midd], pol[(midd + 1) % n]) == crossproduct(a, pol[l], pol[(l + 1) % n])) { al = midd; } else { ar = midd; } } if(crossproduct(a, pol[l], pol[(l + 1) % n])) { return al - l + 1; } else { return (r - l + 1) - (al - l + 1); } } bool solve(int x, int y) { bool a = crossproduct({x, y}, pol[0], pol[1 % n]); bool b = crossproduct({x, y}, pol[n / 2], pol[(n / 2 + 1) % n]); if(a == b) { return a; } return check({x, y}, 0, n / 2 - 1) + check({x, y}, n / 2, n - 1) > n / 2; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t >> n; pol.resize(n); for(int i = 0; i < n; i++) { cin >> pol[i].first >> pol[i].second; } int q; cin >> q; int preans = 0; while(q--) { int x, y; cin >> x >> y; x ^= t * preans * preans * preans; y ^= t * preans * preans * preans; int ans = solve(x, y); preans += ans; if(ans) { cout << "DA\n"; } else { cout << "NE\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...