Submission #276942

#TimeUsernameProblemLanguageResultExecution timeMemory
276942thebesTrampoline (info1cup20_trampoline)C++14
100 / 100
1165 ms57312 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; #define F first #define S second const int MN = 2e5+5, LG = 19; int R, C, N, T, i, j, x, y, a, b, s, t, sp[LG][MN], nxt, rev[MN]; map<int,int> mp, st[MN]; pii pnt[MN]; int main(){ scanf("%d%d%d",&R,&C,&N); for(i=1;i<=N;i++){ scanf("%d%d",&x,&y); pnt[i]={x,y}; mp[x] = 0; } for(auto it=mp.begin();it!=mp.end();it++) it->second = ++nxt, rev[nxt] = it->first; for(i=1;i<=N;i++) st[mp[pnt[i].F]][pnt[i].S]=i; for(i=1;i<=N;i++){ x = mp[pnt[i].F]; if(rev[x]+1==rev[x+1]){ auto it=st[x+1].lower_bound(pnt[i].S); if(it!=st[x+1].end()){ sp[0][i]=it->S; } } } for(j=1;j<LG;j++){ for(i=1;i<=N;i++){ if(sp[j-1][i]&&sp[j-1][sp[j-1][i]]) sp[j][i]=sp[j-1][sp[j-1][i]]; } } scanf("%d",&T); while(T--){ scanf("%d%d%d%d",&x,&y,&a,&b); if(x==a) printf("%s\n",y<=b?"Yes":"No"); else{ s = t = 0; auto it=st[mp[x]].lower_bound(y); if(it!=st[mp[x]].end()) s = it->S; it=st[mp[a-1]].upper_bound(b); if(it!=st[mp[a-1]].begin()&&st[mp[a-1]].size()){ it--; t = it->S; } if(!s||!t) printf("No\n"); else{ int dis = a-x-1; for(j=LG-1;j>=0;j--){ if(dis&(1<<j)) s = sp[j][s]; } if(!s) printf("No\n"); else if(pnt[s].F==pnt[t].F&&pnt[s].S<=pnt[t].S) printf("Yes\n"); else printf("No\n"); } } } return 0; }

Compilation message (stderr)

trampoline.cpp: In function 'int main()':
trampoline.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d%d%d",&R,&C,&N);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
trampoline.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
trampoline.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |     scanf("%d",&T);
      |     ~~~~~^~~~~~~~~
trampoline.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         scanf("%d%d%d%d",&x,&y,&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...