This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
struct Point {
ll x, y;
};
const int nax = 1e5 + 10;
int t, n, q;
Point p[nax];
ll det(Point a, Point b, Point c) {
return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> t >> n;
for(int i = 0; i < n; ++i) {
cin >> p[i].x >> p[i].y;
}
int cnt = 0;
cin >> q;
while(q--) {
ll a, b;
cin >> a >> b;
a ^= (ll)cnt * cnt * cnt * t;
b ^= (ll)cnt * cnt * cnt * t;
bool sign = det(p[0], p[1], {a, b}) >= 0;
int r = 0;
for(int i = 1; i < n; ++i) {
if((det(p[i], p[(i + 1) % n], {a, b}) >= 0) == sign) {
r = i;
} else {
break;
}
}
int l = 0;
for(int i = n - 1; i >= 1; --i) {
if((det(p[i], p[(i + 1) % n], {a, b}) >= 0) == sign) {
l = i;
} else {
break;
}
}
//cout << sign << " " << l << " " << r << "\n";
bool w = false;
if(r == n - 1) {
if(sign) w = true;
} else {
if(sign) {
if(((n - l) % n) + r + 1 > n / 2) w = true;
} else {
if(((n - l) % n) + r + 1 < n / 2) w = true;
}
}
cnt += w;
if(w) 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... |