Submission #1041348

#TimeUsernameProblemLanguageResultExecution timeMemory
1041348elotelo966Trampoline (info1cup20_trampoline)C++17
0 / 100
496 ms62232 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define int long long #define OYY LLONG_MAX #define mod 998244353 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define FOR for(int i=1;i<=n;i++) #define mid (start+end)/2 #define lim 200005 #define fi first #define se second vector<pair<int,int>> v[lim]; int x[lim],y[lim]; set<int> st; map<int,int> mp; int timer,l; int up[lim][25]; int32_t main(){ faster int r,c,n;cin>>r>>c>>n; l=ceil(log2(n)); FOR{ cin>>x[i]>>y[i]; st.insert(x[i]); } for(auto a:st){ mp[a]=++timer; } FOR{ v[mp[x[i]]].push_back({y[i],i}); } for(int i=1;i<=timer;i++){ sort(v[i].begin(),v[i].end()); } FOR{ if(mp.find(x[i]+1)==mp.end())continue; if(v[mp[x[i]+1]].back().fi<y[i])continue; int tut=lower_bound(v[mp[x[i]+1]].begin(),v[mp[x[i]+1]].end(),make_pair(y[i],0ll))-v[mp[x[i]+1]].begin(); up[i][0]=v[mp[x[i]+1]][tut].se; } for(int i=1;i<=l;i++){ for(int j=1;j<=n;j++){ up[j][i]=up[up[j][i-1]][i-1]; } } int q;cin>>q; while(q--){ int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2; if(y1>y2){ cout<<"No"<<'\n'; continue; } if(x1==x2){ cout<<"Yes"<<'\n'; continue; } if(x1>x2){ cout<<"No"<<'\n'; continue; } if(v[mp[x1]].back().fi<y1){ cout<<"No"<<'\n'; continue; } int node=lower_bound(v[mp[x1]].begin(),v[mp[x1]].end(),make_pair(y1,0ll))-v[mp[x1]].begin(); node=v[mp[x1]][node].se; for(int i=l;i>=0;i--){ if(!up[node][i] && x[up[node][i]]<x2){ node=up[node][i]; } } if(y[node]<=y2)cout<<"Yes"<<'\n'; else cout<<"No"<<'\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...