#include <algorithm>
#include <iostream>
#define endl '\n'
using namespace std;
const int MAXN = 200000;
const int LOG = 20;
struct trampoline
{
int x, y;
};
trampoline a[MAXN + 5];
int Next[MAXN + 5][LOG + 5];
bool cmp(trampoline a, trampoline b)
{
if (a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
int main()
{
ios :: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int R, C, N;
cin >> R >> C >> N;
for (int i = 1; i <= N; ++ i)
{
cin >> a[i].x >> a[i].y;
}
sort(a + 1, a + N + 1, cmp);
for (int i = 1; i <= N; ++ i)
{
trampoline curr;
curr.x = a[i].x + 1;
curr.y = a[i].y;
int l = 0, r = N + 1, mid;
while (l < r - 1)
{
mid = (l + r) / 2;
if (curr.x > a[mid].x or (curr.x == a[mid].x and curr.y > a[mid].y)) l = mid;
else r = mid;
}
if (r == N + 1 or a[i].x + 1 != a[mid].x) Next[i][0] = -1;
else Next[i][0] = r;
}
for (int j = 1; j <= LOG; ++ j)
{
for (int i = 1; i <= N; ++ i)
{
Next[i][j] = Next[Next[i][j - 1]][j - 1];
}
}
int T;
cin >> T;
for (int i = 1; i <= T; ++ i)
{
int x_start, y_start, x_stop, y_stop;
cin >> x_start >> y_start >> x_stop >> y_stop;
if (x_start > x_stop or (x_start == x_stop and y_start > y_stop))
{
cout << "No" << endl;
continue;
}
if (x_start == x_stop)
{
cout << "Yes" << endl;
continue;
}
trampoline curr;
curr.x = x_start;
curr.y = y_start;
int l = 0, r = N + 1, mid;
while (l < r - 1)
{
mid = (l + r) / 2;
if (curr.x > a[mid].x or (curr.x == a[mid].x and curr.y > a[mid].y)) l = mid;
else r = mid;
}
if (r == N + 1 or a[r].x > x_start)
{
cout << "No" << endl;
continue;
}
int t = r;
x_start = a[t].x;
y_start = a[t].y;
for (int j = LOG; j >= 0; -- j)
{
if (x_start + (1ll << j) < x_stop)
{
t = Next[t][j];
if (t == -1) break;
x_start = a[t].x;
y_start = a[t].y;
}
}
x_start++;
if (t == -1 or x_start > x_stop or y_start > y_stop) cout << "No" << endl;
else cout << "Yes" << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1260 KB |
expected NO, found YES [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
21484 KB |
expected NO, found YES [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
299 ms |
22380 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
303 ms |
22252 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
304 ms |
22252 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
305 ms |
22244 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
298 ms |
22260 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
308 ms |
22320 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
876 KB |
expected YES, found NO [35th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
321 ms |
22380 KB |
expected NO, found YES [22nd token] |
2 |
Halted |
0 ms |
0 KB |
- |