#include <bits/stdc++.h>
using namespace std;
#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using uint = uint32_t;
using ull = uint64_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const ll LINF = ll(1e18) + ll(1e15);
static auto LamyIsCute = []() {
EmiliaMyWife
return 48763;
}();
signed main() {
int r, c, n;
cin >> r >> c >> n;
vector<pair<int, int>> arr(n);
for(int i = 0; i < n; i++)
cin >> arr[i].first >> arr[i].second;
sort(arr.begin(), arr.end());
vector<vector<int>> nxt(20, vector<int>(n));
for(int i = 0; i < n; i++) {
auto l = lower_bound(arr.begin(), arr.end(), make_pair(arr[i].first + 1, arr[i].second));
if(l == arr.end() || l->first != arr[i].first + 1)
nxt[0][i] = n;
else
nxt[0][i] = l - arr.begin();
}
for(int i = 1; i < 20; i++)
for(int j = 0; j < n; j++)
nxt[i][j] = (nxt[i - 1][j] < n ? nxt[i - 1][nxt[i - 1][j]] : n);
int q;
cin >> q;
auto query = [&]() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if(x1 > x2 || y1 > y2)
return false;
if(x1 == x2)
return true;
auto it = lower_bound(arr.begin(), arr.end(), make_pair(x1, y1)) - arr.begin();
if(it == n || arr[it].first != x1)
return false;
for(int i = 19; ~i; i--) {
if(nxt[i][it] < n && arr[nxt[i][it]].first < x2)
it = nxt[i][it];
}
return arr[it].first == x2 - 1 && arr[it].second <= y2;
};
while(q--) {
cout << (query() ? "Yes" : "No") << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1100 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
4 ms |
1160 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
844 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
18356 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
82 ms |
18268 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
83 ms |
18372 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
82 ms |
18268 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
18272 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
249 ms |
18260 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
263 ms |
18372 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
280 ms |
18264 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
306 ms |
18256 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
260 ms |
18256 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
716 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
6 ms |
716 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
5 ms |
716 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
5 ms |
716 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
7 ms |
780 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
5 ms |
716 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
389 ms |
25876 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
392 ms |
30008 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
283 ms |
30004 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
408 ms |
29896 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
310 ms |
29872 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
304 ms |
30084 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
294 ms |
30004 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
271 ms |
29992 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
366 ms |
29876 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
399 ms |
29956 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
409 ms |
29876 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
243 ms |
30016 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
270 ms |
29996 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
310 ms |
30000 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
254 ms |
29940 KB |
200000 token(s): yes count is 129674, no count is 70326 |