Submission #369939

#TimeUsernameProblemLanguageResultExecution timeMemory
369939A_DTrampoline (info1cup20_trampoline)C++14
66 / 100
537 ms47600 KiB
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second #define du long double using namespace std; const int N=4e5+1000; const int l=20; int nxt[N][l]; vector<ii> vec; main() { int r,c,n; cin>>r>>c>>n; for(int i=1;i<=n;i++){ int a,b; scanf("%lld",&a); scanf("%lld",&b); vec.push_back({a,b}); } sort(vec.begin(),vec.end()); int sz=vec.size(); for(int i=0;i<l;i++)nxt[sz][i]=sz; for(int i=0;i<sz;i++){ int nx=lower_bound(vec.begin(),vec.end(),make_pair(vec[i].F+1,vec[i].S))-vec.begin(); if(nx!=sz&&vec[nx].F!=vec[i].F+1){ nx=sz; } nxt[i][0]=nx; } for(int j=1;j<l;j++){ for(int i=0;i<sz;i++){ nxt[i][j]=nxt[nxt[i][j-1]][j-1]; } } vec.push_back({1e10,1e10}); // for(int i=0;i<vec.size();i++)cout<<i<<" "<<vec[i].F<<" "<<vec[i].S<<endl; // cout<<endl; /*for(int i=0;i<sz;i++){ for(int j=0;j<l;j++){ cout<<nxt[i][j]<<" "; } cout<<endl; }*/ int t; cin>>t; while(t--){ int x1,x2,y1,y2; scanf("%lld",&x1); scanf("%lld",&y1); scanf("%lld",&x2); scanf("%lld",&y2); if(y2<y1||x2<x1){ // cout<<1; printf("No\n"); continue; } if(x1==x2){ printf("Yes\n"); continue; } int i=lower_bound(vec.begin(),vec.end(),make_pair(x1,y1))-vec.begin(); for(int j=l-1;j>=0;j--){ if(((x2-x1-1)&(1<<j))){ if(i != sz) i = nxt[i][j]; } } // cout<<i<<endl; int l=vec[i].S; if(vec[i].S<=y2){ printf("Yes\n"); continue; } int r=nxt[i][0]; r=vec[r].S; // cout<<i<<endl; if(l<=y2&&y2<=r){ printf("Yes\n"); continue; } printf("No\n"); } }

Compilation message (stderr)

trampoline.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      |      ^
trampoline.cpp: In function 'int main()':
trampoline.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%lld",&a);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         scanf("%lld",&b);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |         scanf("%lld",&x1);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |         scanf("%lld",&y1);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |         scanf("%lld",&x2);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:53:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   53 |         scanf("%lld",&y2);
      |         ~~~~~^~~~~~~~~~~~
#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...