# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332229 | evpipis | Trampoline (info1cup20_trampoline) | C++11 | 469 ms | 37996 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int, int> ii;
const int len = 2e5+5, lg = 30, inf = 1e9+5;
ii point[len];
int k, dp[len][lg];
int fir(int x, int y){
int l = 1, r = k, ans = k+1;
while (l <= r){
int mid = (l+r)/2;
if (point[mid] >= mp(x, y))
ans = mid, r = mid-1;
else
l = mid+1;
}
if (ans == k+1 || point[ans].fi > x)
return 0;
return ans;
}
int main(){
int n, m, q;
scanf("%d %d %d", &n, &m, &k);
for (int i = 1; i <= k; i++)
scanf("%d %d", &point[i].fi, &point[i].se);
point[0] = mp(inf, inf);
sort(point+1, point+1+k);
for (int i = 1; i <= k; i++)
dp[i][0] = fir(point[i].fi+1, point[i].se);
for (int j = 1; j < lg; j++)
for (int i = 1; i <= k; i++)
dp[i][j] = dp[dp[i][j-1]][j-1];
scanf("%d", &q);
while (q--){
int x1, y1, x2, y2;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
if (x1 > x2 || y1 > y2)
printf("No\n");
else if (x1 == x2)
printf("Yes\n");
else{
int i = fir(x1, y1), dif = x2-x1-1;
for (int j = 0; j < lg; j++)
if (dif&(1<<j))
i = dp[i][j];
if (point[i].se <= y2)
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |