#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA
const int lgmx = 18;
void solve() {
int R, C, N; cin >> R >> C >> N;
vector<pii> green_vec(N);
map<int, set<pii>> green;
for (int i = 0, r, c; i < N; ++i) cin >> r >> c, green_vec[i] = {r, c}, green[r].ee(c, i);
vector anc(lgmx, vector<int>(N+1, N));
for (const auto &[r, st_c] : green) {
if (!green.count(r+1)) continue;
const set<pii> &nxt = green[r+1];
for (const auto &[c, id] : st_c) {
const auto it = nxt.lower_bound({c, 0});
if (it == end(nxt)) break;
anc[0][id] = it->second;
}
}
for (int lay = 1; lay < lgmx; ++lay) {
for (int i = 0; i < N; ++i) anc[lay][i] = anc[lay-1][anc[lay-1][i]];
}
int T; cin >> T;
for (int q = 1; q <= T; ++q) {
int sx, sy, ex, ey; cin >> sx >> sy >> ex >> ey;
if (sx > ex or (sx == ex and sy > ey)) {cout << "No" << "\n"; continue;}
if (sx == ex) {cout << "Yes" << "\n"; continue;}
if (!green.count(sx) or green[sx].lower_bound({sy, 0}) == end(green[sx])) {cout << "No" << "\n"; continue;}
int dif = ex - sx - 1, now = green[sx].lower_bound({sy, 0})->second;
for (int lay = lgmx-1; lay >= 0; --lay) {
if (dif >> lay & 1) now = anc[lay][now];
}
if (now < N and green_vec[now].second <= ey) cout << "Yes" << "\n";
else cout << "No" << "\n";
}
}
int32_t main() {
fastIO();
int t = 1; // cin >> t;
for (int _ = 1; _ <= t; ++_) {
solve();
}
return 0;
}
#else
#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// #define int int64_t
// #define double __float80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;
// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())
#ifdef local
#define fastIO() void()
#define debug(...) \
fprintf(stderr, "%sAt [%s], line %d: (%s) = ", "\u001b[33m", __FUNCTION__, __LINE__, #__VA_ARGS__), \
_do(__VA_ARGS__), fprintf(stderr, "%s", "\u001b[0m")
template <typename T> void _do(T &&_t) {cerr << _t << "\n";}
template <typename T, typename ...U> void _do(T &&_t, U &&..._u) {cerr << _t << ", ", _do(_u...);}
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T, typename U> bool chmin(T &lhs, U rhs) {return lhs > rhs ? lhs = rhs, 1 : 0;}
template <typename T, typename U> bool chmax(T &lhs, U rhs) {return lhs < rhs ? lhs = rhs, 1 : 0;}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1364 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
4 ms |
1620 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
1236 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
138 ms |
26400 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
137 ms |
26424 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
127 ms |
26236 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
120 ms |
26424 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
284 ms |
26132 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
292 ms |
26184 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
281 ms |
26208 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
299 ms |
26328 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
299 ms |
26348 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
416 ms |
32452 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
980 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
5 ms |
980 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
6 ms |
1364 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
5 ms |
976 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
6 ms |
1108 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
5 ms |
980 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
533 ms |
41232 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
458 ms |
39716 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
305 ms |
37892 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
591 ms |
56492 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
440 ms |
44500 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
309 ms |
37816 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
308 ms |
37812 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
296 ms |
37840 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
532 ms |
43924 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
502 ms |
44144 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
549 ms |
50352 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
314 ms |
37852 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
291 ms |
37828 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
333 ms |
38132 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
274 ms |
37816 KB |
200000 token(s): yes count is 129674, no count is 70326 |