Submission #1008900

#TimeUsernameProblemLanguageResultExecution timeMemory
1008900PenguinsAreCuteTrampoline (info1cup20_trampoline)C++17
62 / 100
2043 ms65984 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 420690; const int INF = 1210201069; #pragma GCC optimize("O3") vector<pair<int,int>> seg[MAXN<<1]; int f(int i, int x) {return (*lower_bound(seg[i].begin(),seg[i].end(),make_pair(x,0))).second;} void build() { for(int i=MAXN;i--;) { int ptr = 0; for(auto [j, k]: seg[i<<1]) { while(seg[i<<1|1][ptr].first<k) ptr++; seg[i].push_back({j,seg[i<<1|1][ptr].second}); } } } int qry(int l, int r, int x) { stack<int> st; for(l+=MAXN,r+=MAXN;l<r;l>>=1,r>>=1) { if(l&1) x=f(l++,x); if(r&1) st.push(--r); } while(st.size()) { x=f(st.top(),x); st.pop(); } return x; } int read() { int x = 0; char c; c=getchar_unlocked(); while(c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c&15); c=getchar_unlocked(); } return x; } main() { int r, c, n; r = read(); c = read(); n = read(); vector<int> v; int x[n], y[n]; for(int i=0;i<n;i++) { x[i]=read();y[i]=read(); v.push_back(x[i]); v.push_back(x[i]+1); } sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end())-v.begin()); for(int i=0;i<n;i++) x[i]=lower_bound(v.begin(),v.end(),x[i])-v.begin(); for(int i=0;i<n;i++) seg[x[i]+MAXN].push_back({y[i],y[i]}); for(int i=0;i<n;i++) sort(seg[x[i]+MAXN].begin(),seg[x[i]+MAXN].end()); for(int i=0;i<MAXN;i++) seg[i+MAXN].push_back({INF,INF}); build(); int t = read(); while(t--) { int x1, y1, x2, y2; x1=read();y1=read();x2=read();y2=read(); if(x1==x2) { cout << (y1<=y2?"Yes\n":"No\n"); continue; } if(x1>x2) { cout << "No\n"; continue; } auto it1 = lower_bound(v.begin(),v.end(),x1); auto it2 = lower_bound(v.begin(),v.end(),x2); if(it1==v.end()||it2==v.end()||(*it1)!=x1||(*it2)!=x2) { cout << "No\n"; continue; } cout << (qry(it1-v.begin(),it2-v.begin(),y1)<=y2?"Yes\n":"No\n"); } }

Compilation message (stderr)

trampoline.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   39 | main() {
      | ^~~~
trampoline.cpp: In function 'int main()':
trampoline.cpp:40:6: warning: variable 'r' set but not used [-Wunused-but-set-variable]
   40 |  int r, c, n; r = read(); c = read(); n = read();
      |      ^
trampoline.cpp:40:9: warning: variable 'c' set but not used [-Wunused-but-set-variable]
   40 |  int r, c, n; r = read(); c = read(); n = read();
      |         ^
#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...