Submission #520271

#TimeUsernameProblemLanguageResultExecution timeMemory
520271amunduzbaevTrampoline (info1cup20_trampoline)C++14
30 / 100
725 ms96656 KiB
#include "bits/stdc++.h" using namespace std; #define ar array #define int long long signed main(){ ios::sync_with_stdio(0); cin.tie(0); int r, c, n; cin>>r>>c>>n; vector<ar<int, 2>> t(n); for(int i=0;i<n;i++) cin>>t[i][0]>>t[i][1]; sort(t.begin(), t.end()); vector<vector<int>> in(n, vector<int>(20, -1)); map<int, vector<ar<int, 2>>> mm; for(int i=0;i<n;i++){ mm[t[i][0]].push_back({t[i][1], i}); } for(auto& [x, v] : mm) sort(v.begin(), v.end()); //~ for(int i=0;i<n;i++){ //~ cout<<t[i][0]<<" "<<t[i][1]; //~ cout<<"\n"; //~ } cout<<"\n"; for(int i=n-1;~i;i--){ if(mm.count(t[i][0] + 1)){ auto& v = mm[t[i][0] + 1]; auto it = lower_bound(v.begin(), v.end(), (ar<int, 2>){t[i][1], -1}); //~ for(auto x : v) cout<<x[0]<<" "<<x[1]<<"\n"; if(it != v.end()){ in[i][0] = (*it)[1]; } } for(int j=1;j<20;j++){ if(in[i][j-1] == -1) continue; in[i][j] = in[in[i][j-1]][j-1]; } } //~ for(int j=0;j<5;j++){ //~ for(int i=0;i<n;i++){ //~ cout<<in[i][j]<<" "; //~ } cout<<"\n"; //~ } int m; cin>>m; while(m--){ ar<int, 2> a, b; cin>>a[0]>>a[1]>>b[0]>>b[1]; if(b[0] < a[0] || b[1] < a[1]){ cout<<"No\n"; continue; } if(a[0] == b[0]){ cout<<"Yes\n"; continue; } int d = b[0] - a[0] - 1; if(d > n) { cout<<"No\n"; continue; } auto& v = mm[a[0]]; auto it = lower_bound(v.begin(), v.end(), (ar<int, 2>){a[1], -1}); if(it == v.end()){ cout<<"No\n"; continue; } int i = (*it)[1]; for(int j=19;~j;j--){ if(d >> j & 1){ i = in[i][j]; } } if(~i && t[i][1] <= b[1]){ cout<<"Yes\n"; } else { cout<<"No\n"; } } }

Compilation message (stderr)

trampoline.cpp: In function 'int main()':
trampoline.cpp:20:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |  for(auto& [x, v] : mm) sort(v.begin(), v.end());
      |            ^
#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...