#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 or c1 > c2){ cout<<"No"<<"\n"; continue; }
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";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1448 KB |
expected NO, found YES [7th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
364 ms |
25256 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1109 ms |
46132 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
1071 ms |
44480 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
1115 ms |
44392 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
1240 ms |
44748 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
1050 ms |
44632 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
1192 ms |
50644 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
1612 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1344 ms |
51784 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |