#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
const int mx = 2e5 + 5, ml = 18;
int R, C, n, q, col[mx], down[mx][ml]; map<int, set<pair<int, int>>> mp;
int main(){
cin >> R >> C >> n;
FOR(i, 1, n + 1){
int r, c; cin >> r >> c;
col[i] = c;
mp[r].insert({c, i});
}
for (auto [r, S] : mp)
for (auto [c, idx] : S){
auto it = mp[c + 1].upper_bound({r, 1e9});
if (it != mp[c + 1].end()) down[idx][0] = it->second;
}
FOR(l, 1, ml) FOR(i, 1, n + 1) down[i][l] = down[down[i][l - 1]][l - 1];
cin >> q;
while (q--){
int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
if (r1 == r2){ cout<<"Yes"<<"\n"; continue; }
auto st = mp[r1].lower_bound({c1, -1});
int cur = (st == mp[r1].end()) ? 0 : st->second;
int jmp = r2 - r1 - 1;
FOR(l, 0, ml) if ((jmp >> l) & 1) cur = down[cur][l];
cout<<((!cur or col[cur] > c2) ? "No" : "Yes")<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1360 KB |
expected NO, found YES [7th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
342 ms |
26644 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1207 ms |
57408 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
1163 ms |
55804 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
1110 ms |
55612 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
1166 ms |
56064 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
1085 ms |
55924 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
1142 ms |
61952 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1616 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1176 ms |
63232 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |