#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 = 32 - __builtin_clz(n + 1);
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()) {
to[0][i] = n + 1;
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 + 1) {
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
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 |
1 |
Correct |
6 ms |
2380 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
7 ms |
2764 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
4 ms |
1868 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
246 ms |
55284 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
254 ms |
55276 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
244 ms |
55168 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
255 ms |
55292 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
55788 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
378 ms |
55852 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
425 ms |
55792 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
422 ms |
56104 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
450 ms |
55972 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
529 ms |
59964 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1484 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
7 ms |
1484 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
7 ms |
1816 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
6 ms |
1484 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
7 ms |
1612 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
6 ms |
1476 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
669 ms |
60984 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
597 ms |
57140 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
434 ms |
55840 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
783 ms |
68444 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
530 ms |
60360 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
433 ms |
55928 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
433 ms |
55812 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
415 ms |
55864 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
645 ms |
60284 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
661 ms |
60068 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
715 ms |
64192 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
343 ms |
55928 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
355 ms |
55804 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
490 ms |
56044 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
397 ms |
67672 KB |
200000 token(s): yes count is 129674, no count is 70326 |