이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |