#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma warning(disable : 6031)
#define USACO freopen("moocast.in", "r", stdin); freopen("moocast.out", "w+", stdout)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
using namespace std;
ll binpow(ll a, ll x, ll m) {
ll ans = 1, md = a % m;
for (int i = 0; i < 63; i++) {
if (x & ((ll)1 << i)) ans = (ans * md) % m;
md = (md * md) % m;
}
return ans;
}
vector<ll> gcd(ll a, ll b) {
if (b == 0) {
return { a, 1, 0 };
}
vector<ll> d = gcd(b, a % b);
return { d[0], d[2], d[1] - d[2] * (a / b) };
}
ll lcm(ll a, ll b) {
return a * b / gcd(a, b)[0];
}
pair<int, int> p[200000];
int f[200000], binlft[32][200001];
void solve() {
int r, c, n, T;
cin >> r >> c >> n;
for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
sort(p, p + n);
for (int i = 0; i < n; i++) {
int j = lower_bound(p, p + n, pair<int, int>{p[i].first + 1, p[i].second}) - p;
if (j == n || p[j].first > p[i].first + 1) f[i] = n;
else f[i] = j;
}
for (int i = 0; i < n; i++) binlft[0][i] = f[i];
for (int i = 0; i <= 30; i++) binlft[i][n] = n;
for (int k = 1; k <= 30; k++) {
for (int i = 0; i < n; i++) binlft[k][i] = binlft[k - 1][binlft[k - 1][i]];
}
cin >> T;
while (T--) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 > x2) {
cout << "No\n";
continue;
}
if (x1 == x2) {
if (y1 <= y2) cout << "Yes\n";
else cout << "No\n";
continue;
}
x2--;
int green = lower_bound(p, p + n, pair<int, int>{ x1, y1 }) - p, dist = x2 - x1;
if (green == n || p[green].first != x1) {
cout << "No\n";
continue;
}
for (int bit = 30; bit >= 0; bit--) {
if (dist & (1 << bit)) green = binlft[bit][green];
}
if (green != n && p[green].second <= y2) cout << "Yes\n";
else cout << "No\n";
}
}
int main() {
//USACO;
fastIO;
solve();
}
Compilation message
trampoline.cpp:2: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
2 | #pragma warning(disable : 4996)
|
trampoline.cpp:3: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
3 | #pragma warning(disable : 6031)
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1620 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
4 ms |
1876 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
1496 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
27312 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
71 ms |
27216 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
78 ms |
27256 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
72 ms |
27344 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
28376 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
195 ms |
28212 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
188 ms |
28096 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
196 ms |
28080 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
199 ms |
28084 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
186 ms |
28040 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1492 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
8 ms |
1496 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
5 ms |
1388 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
6 ms |
1492 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
5 ms |
1364 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
5 ms |
1492 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
275 ms |
28704 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
285 ms |
27984 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
191 ms |
27872 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
316 ms |
27868 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
208 ms |
27856 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
192 ms |
27928 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
190 ms |
27916 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
205 ms |
27824 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
275 ms |
27948 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
281 ms |
27928 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
278 ms |
27940 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
191 ms |
27808 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
183 ms |
27792 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
264 ms |
27920 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
184 ms |
27816 KB |
200000 token(s): yes count is 129674, no count is 70326 |