이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
#define int long long
using i128 = __int128;
using point = pair<int, int>;
const int SIZE = 1e5 + 5;
int t, n, q, cur;
point p[SIZE];
i128 cross(point a, point b) {
return (i128) a.F * b.S - (i128) a.S * b.F;
}
point operator - (point a, point b) {
return point(a.F - b.F, a.S - b.S);
}
bool check(point P, int i) {
int j = i + 1 > n ? 1 : i + 1;
return cross(P - p[i], P - p[j]) > 0;
}
void solve() {
cin >> t >> n;
FOR (i, 1, n) cin >> p[i].F >> p[i].S;
cin >> q;
while (q--) {
point P;
cin >> P.F >> P.S;
P.F ^= t * cur * cur * cur;
P.S ^= t * cur * cur * cur;
int x = check(P, 1), y = check(P, n / 2 + 1);
if (x == y) {
if (x) cout << "DA\n", cur++;
else cout << "NE\n";
continue;
}
int xl = 1, xr = n / 2;
while (xl < xr) {
int mid = (xl + xr) / 2 + 1;
if (check(P, mid) == x) xl = mid;
else xr = mid - 1;
}
int yl = n / 2 + 1, yr = n;
while (yl < yr) {
int mid = (yl + yr) / 2 + 1;
if (check(P, mid) == y) yl = mid;
else yr = mid - 1;
}
int len;
if (x == 1) len = xl + n - yl;
else len = yl - xl;
if (len > n / 2) cout << "DA\n", cur++;
else cout << "NE\n";
}
}
int32_t main() {
Waimai;
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |