Submission #895499

#TimeUsernameProblemLanguageResultExecution timeMemory
895499jellybeanTrampoline (info1cup20_trampoline)C++17
0 / 100
128 ms80748 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...