#include <bits/stdc++.h>
using namespace std;
#define int long long
int par[200005];
pair<int,int>arr[200005];
int twok[200005][21];
int findp(int x, int k){
for(int i=0; i<21; i++){
if(k&(1<<i)) x=twok[x][i];
if(x==-1) return -1;
}
return x;
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int r,c,n; cin>>r>>c>>n;
for(int i=0; i<n; i++){
int a,b; cin>>a>>b;
arr[i] = {a,b};
}
sort(arr,arr+n);
for(int i=0; i<n; i++){
pair<int,int>p = arr[i];
p.first++;
auto it = lower_bound(arr,arr+n,p);
if(it==arr+n) par[i] = -1;
else if(it->first > p.first) par[i] = -1;
else par[i] = it-arr;
}
for(int i=0; i<n; i++) twok[i][0] = par[i];
for(int k=1; k<21; k++){
for(int x=0; x<n; x++){
int half = twok[x][k-1];
if(half==-1) twok[x][k] = -1;
else twok[x][k] = twok[half][k-1];
}
}
int t; cin>>t;
while(t--){
int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
if(x2<x1 or y2<y1){cout<<"No\n"; continue;}
if(x1==x2){cout<<"Yes\n"; continue;}
pair<int,int>p = {x1,y1};
auto it = lower_bound(arr,arr+n,p);
if(it==arr+n){cout<<"No\n"; continue;}
if(it->first > x1){cout<<"No\n"; continue;}
int P = findp(x1,x2-x1);
if(P==-1 or arr[P].second > y2)cout<<"No\n";
else cout<<"Yes\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
6748 KB |
expected YES, found NO [5th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
85 ms |
39876 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
114 ms |
80748 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
13656 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
128 ms |
80720 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |