Submission #1087034

#TimeUsernameProblemLanguageResultExecution timeMemory
1087034TrinhKhanhDungTrampoline (info1cup20_trampoline)C++14
0 / 100
378 ms37924 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define sz(x) (int)x.size() #define ALL(v) v.begin(),v.end() #define MASK(k) (1LL << (k)) #define BIT(x, i) (((x) >> (i)) & 1) #define oo (ll)1e18 #define INF (ll)1e9 #define MOD (ll)(1007050321) using namespace std; template<class T1, class T2> bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;} template<class T1, class T2> bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;} template<class T1, class T2> void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;} template<class T1, class T2> void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;} template<class T> void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());} const int MAX = 2e5 + 10, LOG = 18; int R, C, N, Q; int d[MAX][LOG]; int X[MAX], Y[MAX]; void solve(){ cin >> R >> C >> N; map<int, vector<pair<int, int>>> mp; for(int i = 1; i <= N; i++){ int x, y; cin >> x >> y; X[i] = x; Y[i] = y; mp[x].push_back(make_pair(y, i)); } for(auto o: mp){ sort(ALL(o.se)); } for(int i = 1; i <= N; i++){ if(!mp.count(X[i] + 1)) continue; auto it = lower_bound(ALL(mp[X[i] + 1]), make_pair(Y[i], 0)); if(it != mp[X[i] + 1].end()){ d[i][0] = it->se; } } for(int j = 1; j < LOG; j++){ for(int i = 1; i <= N; i++){ d[i][j] = d[d[i][j - 1]][j - 1]; } } cin >> Q; while(Q--){ int x, y, u, v; cin >> x >> y >> u >> v; if(u < x){ cout << "No\n"; continue; } if(x == u && v >= y){ cout << "Yes\n"; continue; } auto it = lower_bound(ALL(mp[x]), make_pair(y, 0)); if(it == mp[x].end()){ cout << "No\n"; continue; } int c = it->se; int delta = u - x - 1; for(int i = 0; i < LOG; i++) if(BIT(delta, i)){ c = d[c][i]; } if(c != 0 && Y[c] <= v) cout << "Yes\n"; else cout << "No\n"; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("numtable.inp","r",stdin); // freopen("numtable.out","w",stdout); solve(); return 0; }
#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...