Submission #899361

#TimeUsernameProblemLanguageResultExecution timeMemory
899361votranngocvyZvijezda (COCI19_zvijezda)C++14
110 / 110
104 ms8056 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define pii pair<int,int> #define fi first #define se second #define mp make_pair const int N = 1e5 + 5; pii a[N]; int n,x,y; ld ccw(pii a,pii b,pii c) { return (ld)a.fi * (b.se - c.se) + (ld)b.fi * (c.se - a.se) + (ld)c.fi * (a.se - b.se); } bool calc(int i) { return ccw(a[i],a[(i + 1) % n],mp(x,y)) >= 0; } int tknp(int l,int r) { int low = l,high = r; while (low < high) { int mid = (low + high + 1) / 2; if (calc(l) == calc(mid)) low = mid; else high = mid - 1; } int ans = low - l + 1; if (!calc(l)) return n / 2 - ans; return ans; } bool solve() { int a = calc(0),b = calc(n / 2); if (a == b) return a; return (tknp(0,n / 2 - 1) + tknp(n / 2,n - 1)) >= (n / 2 + 1); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t >> n; for (int i = 0; i < n; i++) cin >> a[i].fi >> a[i].se; int q; cin >> q; int cnt = 0; while (q--) { cin >> x >> y; x ^= t * cnt * cnt * cnt; y ^= t * cnt * cnt * cnt; int ans = solve(); cnt += ans; if (ans) cout << "DA\n"; else cout << "NE\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...