#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
const int MAX_N = 200010, MAX_K = 18;
int R, C, n;
int nxt[MAX_K][MAX_N];
pair<int,int> a[MAX_N];
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> R >> C >> n;
for (int x, y, i = 0;i < n;++i) {
cin >> x >> y;
a[i] = {x, y};
}
sort(a, a+n);
// init
for (int i = n-1, j = n-1;i >= 0;--i) {
auto [x, y] = a[i];
while (j > 0 && a[j-1] >= make_pair(x+1, y))
--j;
auto [nx, ny] = a[j];
if (nx == x+1 && ny >= y)
nxt[0][i] = j;
else
nxt[0][i] = n;
DE(x, y, nx, ny);
}
nxt[0][n] = n;
for (int d = 1;d < MAX_K;++d)
for (int i = 0;i <= n;++i)
nxt[d][i] = nxt[d-1][ nxt[d-1][i] ];
int Q;
cin >> Q;
for (int x1, y1, x2, y2, i = 0;i < Q;++i) {
cin >> x1 >> y1 >> x2 >> y2;
int ind = lower_bound(a, a+n, make_pair(x1, y1)) - a;
auto [x, y] = a[ind];
DE(x1, y1, x, y, x2, y2);
if (x1 > x2 || y2 > y2) {
cout << "No\n";
continue;
}
if (x1 == x2) {
cout << "Yes\n";
continue;
}
if (ind == n || x != x1) {
cout << "No\n";
continue;
}
int d = x2 - x1 - 1;
for (int j = 0;j < MAX_K;++j)
if (d>>j&1) ind = nxt[j][ind];
tie(x, y) = a[ind];
DE(x, y);
if (ind == n || y > y2) {
cout << "No\n";
}
else cout << "Yes\n";
}
}
Compilation message
trampoline.cpp: In function 'int32_t main()':
trampoline.cpp:14:17: warning: statement has no effect [-Wunused-value]
14 | #define DE(...) 0
| ^
trampoline.cpp:47:3: note: in expansion of macro 'DE'
47 | DE(x, y, nx, ny);
| ^~
trampoline.cpp:14:17: warning: statement has no effect [-Wunused-value]
14 | #define DE(...) 0
| ^
trampoline.cpp:66:3: note: in expansion of macro 'DE'
66 | DE(x1, y1, x, y, x2, y2);
| ^~
trampoline.cpp:68:21: warning: self-comparison always evaluates to false [-Wtautological-compare]
68 | if (x1 > x2 || y2 > y2) {
| ~~ ^ ~~
trampoline.cpp:14:17: warning: statement has no effect [-Wunused-value]
14 | #define DE(...) 0
| ^
trampoline.cpp:90:3: note: in expansion of macro 'DE'
90 | DE(x, y);
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1100 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
4 ms |
1236 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
972 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
17840 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
89 ms |
17776 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
75 ms |
17476 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
77 ms |
17856 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
217 ms |
28496 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
212 ms |
28356 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
218 ms |
28272 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
249 ms |
28432 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
224 ms |
28400 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
225 ms |
28228 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1100 KB |
expected NO, found YES [16th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
384 ms |
28324 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Incorrect |
392 ms |
28372 KB |
expected NO, found YES [22020th token] |
3 |
Halted |
0 ms |
0 KB |
- |