제출 #1145092

#제출 시각아이디문제언어결과실행 시간메모리
1145092Robert_juniorTrampoline (info1cup20_trampoline)C++20
73 / 100
2095 ms34636 KiB
#include <bits/stdc++.h> using namespace std; #define ins insert #define pb push_back #define all(x) x.begin(), x.end() #define F first #define S second const int N = 2e5 + 7; int x[N], y[N], to1[N]; map<int, set<int>>mp; pair<int, int>to[N]; map<pair<int, int>, int>mp1; int c, d; string ans; pair<int, int>next(int a, int b){ if(mp[a + 1].size()){ auto it = mp[a + 1].lower_bound(b); if(it != mp[a + 1].end()){ return {a + 1, *it}; } else{ return {-1, -1}; } } else{ return {-1, -1}; } } void dfs(int i){ if(y[i] > d || x[i] > c) return; else if(x[i] == c - 1 && y[i] <= d) ans = "YES\n"; else if(x[i] == c - 1) return; else{ if(to1[i] > 0) dfs(to1[i]); } } void solve(){ int r, w, n, t; cin>>r>>w>>n; for(int i = 1; i <= n; i++){ cin>>x[i]>>y[i]; mp1[{x[i], y[i]}] = i; mp[x[i]].ins(y[i]); } for(int i = 1; i <= n; i++){ to[i] = next(x[i], y[i]); if(to[i].F == -1 && to[i].S == -1){ auto it = mp[x[i]].upper_bound(y[i]); if(it != mp[x[i]].end()){ to[i] = {x[i], *it}; } } if(to[i].F != -1 && to[i].S != -1){ to1[i] = mp1[to[i]]; } } cin>>t; while(t--){ int a, b; cin>>a>>b>>c>>d; if(a == c && b <= d){ cout<<"YES\n"; continue; } if(!mp[a].size() || a > c || b > d){ cout<<"NO\n"; continue; } ans = "NO\n"; auto it = mp[a].lower_bound(b); if(it != mp[a].end()){ b = *it; } dfs(mp1[{a, b}]); cout<<ans; } } signed main(){ ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; //cin>>t; while(t--){ solve(); } }
#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...