#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
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 |
Incorrect |
6 ms |
2360 KB |
expected NO, found YES [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
262 ms |
55592 KB |
expected NO, found YES [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
453 ms |
65984 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
444 ms |
65888 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
438 ms |
65844 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
493 ms |
66032 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
488 ms |
66072 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
570 ms |
69920 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1740 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
7 ms |
1696 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
8 ms |
2068 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
7 ms |
1776 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
8 ms |
1808 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
6 ms |
1740 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
711 ms |
70888 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
669 ms |
67232 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
466 ms |
66092 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
811 ms |
78400 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
618 ms |
70496 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
449 ms |
66120 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
473 ms |
66268 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
429 ms |
66168 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
680 ms |
70108 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
706 ms |
70184 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
759 ms |
74296 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
360 ms |
65992 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
412 ms |
65960 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Incorrect |
554 ms |
66088 KB |
expected NO, found YES [36443rd token] |
15 |
Halted |
0 ms |
0 KB |
- |