# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
276942 | thebes | Trampoline (info1cup20_trampoline) | C++14 | 1165 ms | 57312 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;
typedef pair<int,int> pii;
#define F first
#define S second
const int MN = 2e5+5, LG = 19;
int R, C, N, T, i, j, x, y, a, b, s, t, sp[LG][MN], nxt, rev[MN];
map<int,int> mp, st[MN];
pii pnt[MN];
int main(){
scanf("%d%d%d",&R,&C,&N);
for(i=1;i<=N;i++){
scanf("%d%d",&x,&y);
pnt[i]={x,y};
mp[x] = 0;
}
for(auto it=mp.begin();it!=mp.end();it++)
it->second = ++nxt, rev[nxt] = it->first;
for(i=1;i<=N;i++)
st[mp[pnt[i].F]][pnt[i].S]=i;
for(i=1;i<=N;i++){
x = mp[pnt[i].F];
if(rev[x]+1==rev[x+1]){
auto it=st[x+1].lower_bound(pnt[i].S);
if(it!=st[x+1].end()){
sp[0][i]=it->S;
}
}
}
for(j=1;j<LG;j++){
for(i=1;i<=N;i++){
if(sp[j-1][i]&&sp[j-1][sp[j-1][i]])
sp[j][i]=sp[j-1][sp[j-1][i]];
}
}
scanf("%d",&T);
while(T--){
scanf("%d%d%d%d",&x,&y,&a,&b);
if(x==a) printf("%s\n",y<=b?"Yes":"No");
else{
s = t = 0;
auto it=st[mp[x]].lower_bound(y);
if(it!=st[mp[x]].end()) s = it->S;
it=st[mp[a-1]].upper_bound(b);
if(it!=st[mp[a-1]].begin()&&st[mp[a-1]].size()){
it--;
t = it->S;
}
if(!s||!t) printf("No\n");
else{
int dis = a-x-1;
for(j=LG-1;j>=0;j--){
if(dis&(1<<j)) s = sp[j][s];
}
if(!s) printf("No\n");
else if(pnt[s].F==pnt[t].F&&pnt[s].S<=pnt[t].S) 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... |