Submission #1027637

#TimeUsernameProblemLanguageResultExecution timeMemory
1027637vjudge1Trampoline (info1cup20_trampoline)C++17
11 / 100
711 ms104564 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lo; #define fi first #define se second #define endl "\n" #define pb push_back #define int long long #define fio() 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 ort ((bas+son)/2) #define _ << " " << const lo inf = 1000000000; const lo li = 500005; const lo mod = 1000000007; int n,m,a[li],k,flag,t,x[li],y[li],r,c,xs[li],xh[li],ys[li],yh[li],fa[li][32]; int cev; string s; vector<int> v,vv[li]; int32_t main(void){ fio(); cin>>r>>c>>n; FOR{ cin>>x[i]>>y[i]; v.pb(x[i]); } cin>>t; for(int i=1;i<=t;i++){ cin>>xs[i]>>ys[i]>>xh[i]>>yh[i]; } sort(v.begin(),v.end()); int sayac=0; map<int,int> mpp; for(int i=0;i<(int)v.size();i++){ if(i==0 || v[i]!=v[i-1]){ sayac++; mpp[v[i]]=sayac; } } map<pair<int,int>,int> mapp; for(int i=1;i<=n;i++){ vv[mpp[x[i]]].pb(y[i]); mapp[{x[i],y[i]}]=i; } for(int i=1;i<=sayac;i++)sort(vv[i].begin(),vv[i].end()); for(int i=1;i<=n;i++){ int at=mpp[x[i]]; int tut=lower_bound(vv[at].begin(),vv[at].end(),ys[i])-vv[at].begin(); if(tut==(int)vv[at].size())fa[i][0]=0; else{ int rem=vv[at][tut]; at=mpp[x[i]+1]; tut=lower_bound(vv[at].begin(),vv[at].end(),rem)-vv[at].begin(); if(tut==(int)vv[at].size())fa[i][0]=0; else fa[i][0]=mapp[{x[i]+1,vv[at][tut]}]; } //~ cout<<i _ fa[i][0]<<endl; } for(int j=1;j<=20;j++){ FOR fa[i][j]=fa[fa[i][j-1]][j-1]; } for(int i=1;i<=t;i++){ if(xh[i]==xs[i]){ if(ys[i]<=yh[i]){cout<<"Yes\n";continue;} cout<<"No\n";continue; } if(xh[i]-xs[i]>n){cout<<"No\n";continue;} int at=mpp[xs[i]]; int tut=lower_bound(vv[at].begin(),vv[at].end(),ys[i])-vv[at].begin(); if(tut==(int)vv[at].size()){cout<<"No\n";continue;} int node=mapp[{xs[i],vv[at][tut]}]; //~ cout<<node<<" ()() \n"; for(int j=20;j>=0;j--){ if(fa[node][j]==0 || x[fa[node][j]]>=xh[i])continue; node=fa[node][j]; //~ cout<<fa[node][j] _ node _ j<<" AA\n"; } //~ cout<<i _ node _ x[node] _ y[node]<<endl; if(x[node]!=xh[i]-1){cout<<"No\n";continue;} at=mpp[x[node]]; tut=lower_bound(vv[at].begin(),vv[at].end(),y[node])-vv[at].begin(); if(tut==(int)vv[at].size()){cout<<"No\n";continue;} if(vv[at][tut]>yh[i]){cout<<"No\n";continue;} 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...