#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 |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
408 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
408 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
53 ms |
3844 KB |
Output is correct |
13 |
Correct |
61 ms |
3776 KB |
Output is correct |
14 |
Correct |
67 ms |
4704 KB |
Output is correct |
15 |
Correct |
72 ms |
5324 KB |
Output is correct |
16 |
Correct |
97 ms |
7420 KB |
Output is correct |
17 |
Correct |
139 ms |
7412 KB |
Output is correct |
18 |
Correct |
56 ms |
4524 KB |
Output is correct |
19 |
Correct |
72 ms |
5300 KB |
Output is correct |
20 |
Correct |
86 ms |
6208 KB |
Output is correct |
21 |
Correct |
96 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
7680 KB |
Output is correct |
2 |
Correct |
101 ms |
7896 KB |
Output is correct |
3 |
Correct |
74 ms |
5180 KB |
Output is correct |
4 |
Correct |
99 ms |
7964 KB |
Output is correct |
5 |
Correct |
99 ms |
7948 KB |
Output is correct |
6 |
Correct |
104 ms |
7448 KB |
Output is correct |
7 |
Correct |
99 ms |
7468 KB |
Output is correct |
8 |
Correct |
100 ms |
7988 KB |
Output is correct |
9 |
Correct |
93 ms |
7244 KB |
Output is correct |