#include "bits/stdc++.h"
using namespace std;
#define ar array
#define int long long
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int r, c, n; cin>>r>>c>>n;
vector<ar<int, 2>> t(n);
for(int i=0;i<n;i++) cin>>t[i][0]>>t[i][1];
sort(t.begin(), t.end());
vector<vector<int>> in(n, vector<int>(20, -1));
map<int, vector<ar<int, 2>>> mm;
for(int i=0;i<n;i++){
mm[t[i][0]].push_back({t[i][1], i});
}
for(auto& [x, v] : mm) sort(v.begin(), v.end());
//~ for(int i=0;i<n;i++){
//~ cout<<t[i][0]<<" "<<t[i][1];
//~ cout<<"\n";
//~ } cout<<"\n";
for(int i=n-1;~i;i--){
if(mm.count(t[i][0] + 1)){
auto& v = mm[t[i][0] + 1];
auto it = lower_bound(v.begin(), v.end(), (ar<int, 2>){t[i][1], -1});
//~ for(auto x : v) cout<<x[0]<<" "<<x[1]<<"\n";
if(it != v.end()){
in[i][0] = (*it)[1];
}
}
for(int j=1;j<20;j++){
if(in[i][j-1] == -1) continue;
in[i][j] = in[in[i][j-1]][j-1];
}
}
//~ for(int j=0;j<5;j++){
//~ for(int i=0;i<n;i++){
//~ cout<<in[i][j]<<" ";
//~ } cout<<"\n";
//~ }
int m; cin>>m;
while(m--){
ar<int, 2> a, b; cin>>a[0]>>a[1]>>b[0]>>b[1];
if(b[0] < a[0] || b[1] < a[1]){
cout<<"No\n";
continue;
}
if(a[0] == b[0]){
cout<<"Yes\n";
continue;
}
int d = b[0] - a[0] - 1;
if(d > n) { cout<<"No\n"; continue; }
auto& v = mm[a[0]];
auto it = lower_bound(v.begin(), v.end(), (ar<int, 2>){a[1], -1});
if(it == v.end()){
cout<<"No\n";
continue;
}
int i = (*it)[1];
for(int j=19;~j;j--){
if(d >> j & 1){
i = in[i][j];
}
}
if(t[i][1] <= b[1]){
cout<<"Yes\n";
} else {
cout<<"No\n";
}
}
}
Compilation message
trampoline.cpp: In function 'int main()':
trampoline.cpp:20:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
20 | for(auto& [x, v] : mm) sort(v.begin(), v.end());
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
4684 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
143 ms |
98464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
240 ms |
59064 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
242 ms |
58828 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
244 ms |
58232 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
249 ms |
59500 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
255 ms |
59488 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
338 ms |
64840 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1724 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
8 ms |
1744 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
7 ms |
2128 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
6 ms |
1792 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
6 ms |
1908 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
5 ms |
1788 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
553 ms |
66116 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
434 ms |
61088 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
264 ms |
58324 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
734 ms |
76776 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
381 ms |
64868 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
289 ms |
59236 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
279 ms |
59244 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
284 ms |
58280 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
495 ms |
65036 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
518 ms |
64912 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
590 ms |
70600 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
244 ms |
58204 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
251 ms |
59192 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Runtime error |
182 ms |
100844 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |