This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / (b))
#define all(x) x.begin(), x.end()
#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
#ifdef wiwihorz
#define print(a...) cerr<<"Line "<<__LINE__<<":",kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
#define x first
#define y second
namespace solver {
int r, c, n, lg, ii;
vector<vector<int>> to;
vector<pii> a;
map<int, int> mp;
vector<set<pii>> s;
void init_(int _r, int _c, int _n) {
ii = 0, r = _r, c = _c, n = _n;
lg = 31 - __builtin_clz(n);
to.assign(lg + 1, vector<int>(n + 2, 0));
a.assign(n + 1, {0, 0});
s.assign(n + 1, set<pii>());
}
void solve() {
rep(i, 1, n) {
int x, y;
tie(x, y) = a[i];
if(mp.find(x) == mp.end()) mp[x] = ++ii;
s[mp[x]].insert({y, i});
}
rep(i, 1, n) {
int x, y;
tie(x, y) = a[i];
if(mp.find(x + 1) == mp.end()) continue;
int id = mp[x + 1];
auto it = s[id].lower_bound({y, 0});
if(it == s[id].end()) to[0][i] = n + 1;
else to[0][i] = it -> y;
}
to[0][n + 1] = n + 1;
rep(i, 1, lg) rep(j, 1, n) {
to[i][j] = to[i - 1][to[i - 1][j]];
}
}
int gogo(int x, int v) {
rrep(i, 0, lg) if((v >> i) & 1)
x = to[i][x];
if(x == n + 1) return INF;
else return a[x].y;
}
};
using namespace solver;
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int r, c, n;
cin >> r >> c >> n;
init_(r, c, n);
rep(i, 1, n) cin >> a[i].x >> a[i].y;
solve();
int t; cin >> t;
while(t--) {
int x, y, x1, y1;
cin >> x >> y;
cin >> x1 >> y1;
if(x1 < x || y1 < y) cout << "No\n";
else if(x1 - x > n) cout << "No\n";
else if(x1 == x) cout << "Yes\n";
else if(mp.find(x) == mp.end()) cout << "No\n";
else {
auto it = s[mp[x]].lower_bound({y, 0});
if(it == s[mp[x]].end()) cout << "No\n";
else {
int cur = gogo(it -> y, x1 - x - 1);
if(cur <= y1) cout << "Yes\n";
else cout << "No\n";
}
}
}
return 0;
}
Compilation message (stderr)
trampoline.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
5 | #pragma loop-opt(on)
|
trampoline.cpp:21:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
21 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
| ^~~~
trampoline.cpp:21:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
21 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |