Submission #685918

#TimeUsernameProblemLanguageResultExecution timeMemory
685918Alihan_8Trampoline (info1cup20_trampoline)C++17
100 / 100
774 ms78352 KiB
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long const int N = 2e5+1; int lift[20][N]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int r, c, n; cin >> r >> c >> n; map <int,set<pair<int,int>>> st; vector <pair<int,int>> p(n); for ( int i = 0; i < n; i++ ){ int x, y; cin >> x >> y; st[--x].insert({--y, i+1}); p[i] = {x, y}; } for ( int i = 0; i < n; i++ ){ auto [x, y] = p[i]; if ( !st.count(x+1) ) continue; auto it = st[x+1].lower_bound({y, 0}); if ( it == st[x+1].end() ) continue; lift[0][i+1] = it->second; } for ( int i = 1; i < 20; i++ ){ for ( int j = 1; j <= n; j++ ){ lift[i][j] = lift[i-1][lift[i-1][j]]; } } auto get = [&](int x, int k){ for ( int i = 19; i >= 0; i-- ){ if ( k >> i & 1 ) x = lift[i][x]; } return x; }; int t; cin >> t; while ( t-- ){ int xs, ys, xe, ye; cin >> xs >> ys >> xe >> ye; if ( xs > xe or ys > ye or xe-xs > n ){ cout << "No\n"; continue; } if ( xs == xe ){ cout << "Yes\n"; continue; } xs--, xe--, ys--, ye--; if ( !st.count(xs) ){ cout << "No\n"; continue; } auto it = st[xs].lower_bound({ys, 0}); if ( it == st[xs].end() ){ cout << "No\n"; continue; } int k = it->second, par = xe-xs-1; k = get(k, par); if ( !k or p[k-1].second > ye ) cout << "No\n"; else cout << "Yes\n"; } cout << '\n'; }

Compilation message (stderr)

trampoline.cpp: In function 'void IO(std::string)':
trampoline.cpp:11:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:11:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...