Submission #427806

#TimeUsernameProblemLanguageResultExecution timeMemory
427806errorgornTrampoline (info1cup20_trampoline)C++17
43 / 100
762 ms42660 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<ll,ll> #define fi first #define se second #define endl '\n' #define puf push_front #define pof pop_front #define pub push_back #define pob pop_back #define lb lower_bound #define ub upper_bound #define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--) #define all(x) (x).begin(),(x).end() #define sz(x) (int) (x).size() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int r,c,n,q; ii arr[200005]; int nxt[200005][20];; map<int,vector<ii> > m; int main(){ cin.tie(0); cout.tie(0); cin.sync_with_stdio(false); cin>>r>>c>>n; rep(x,0,n) cin>>arr[x].fi>>arr[x].se; sort(arr,arr+n); rep(x,0,n){ m[arr[x].fi].pub(ii(arr[x].se,x)); } memset(nxt,-1,sizeof(nxt)); rep(x,0,n){ int temp=-1; if (m.count(arr[x].fi+1)){ auto iter=lb(all(m[arr[x].fi+1]),ii(arr[x].se,-1)); if (iter!=m[arr[x].fi+1].end()) temp=(*iter).se; } nxt[x][0]=temp; } rep(x,n,0){ int curr=nxt[x][0]; rep(y,0,20){ if (curr==-1) break; curr=nxt[x][y+1]=nxt[curr][y]; } } cin>>q; int a,b,c,d; while (q--){ cin>>a>>b>>c>>d; //cerr<<a<<" "<<b<<" "<<c<<" "<<d<<endl; if (a>c || b>d){ cout<<"No"<<endl; continue; } if (a==c){ cout<<"Yes"<<endl; continue; } int idx=-1; if (m.count(a)){ auto iter=lb(all(m[a]),ii(b,-1)); if (iter!=m[a].end()) idx=(*iter).se; } if (idx==-1){ cout<<"No"<<endl; continue; } rep(x,20,0) if (nxt[idx][x]!=-1){ if (arr[nxt[idx][x]].se<=d) idx=nxt[idx][x]; } if (c-1<=arr[idx].fi) cout<<"Yes"<<endl; else cout<<"No"<<endl; } }
#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...