#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[r + 1].lower_bound({c, -1});
if (it != mp[r + 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 |
Correct |
7 ms |
1356 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
9 ms |
1488 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
6 ms |
1232 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
264 ms |
24980 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
281 ms |
26720 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
253 ms |
26144 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
263 ms |
26568 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
984 ms |
30712 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
997 ms |
28620 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
1022 ms |
26256 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
1030 ms |
25652 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
946 ms |
25668 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
1057 ms |
31664 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
844 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
24 ms |
1236 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
22 ms |
2160 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
20 ms |
1264 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
21 ms |
1376 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
21 ms |
1372 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1210 ms |
33032 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
1133 ms |
39036 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
1004 ms |
37448 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
1314 ms |
55836 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
1160 ms |
48376 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
1086 ms |
40348 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
1014 ms |
40300 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
948 ms |
38388 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
1240 ms |
43112 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
1250 ms |
43128 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
1255 ms |
49348 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
1006 ms |
42820 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
956 ms |
42412 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
1135 ms |
37172 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
979 ms |
40164 KB |
200000 token(s): yes count is 129674, no count is 70326 |