Submission #987898

# Submission time Handle Problem Language Result Execution time Memory
987898 2024-05-23T18:57:44 Z user736482 Trampoline (info1cup20_trampoline) C++17
100 / 100
1769 ms 79572 KB
#include<bits/stdc++.h>
using namespace std;

int R,C,N,T,a,b,c,d;
vector<pair<int,int>> ziel;
vector<int> point[200007];
pair<int,int>nast[200007];
int nast2[200007],pom[200007];
map<int,vector<int>>zielone;
map<pair<int,int>,int>mp;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>R>>C>>N;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        mp[{a,b}]=i;
        ziel.push_back({a,b});
        zielone[a].push_back(b);
    }
    for(auto i=zielone.begin();i!=zielone.end();i++){
        sort((*i).second.begin(),(*i).second.end());
    }
    //cout<<zielone[2][0]<<" "<<zielone[2][1]<<"     ";
    for(int i=0;i<N;i++){
        //cout<<ziel[i].first<<" "<<ziel[i].second<<"   ";
        if((int)zielone[ziel[i].first+1].size()==0 || zielone[ziel[i].first+1][(int)zielone[ziel[i].first+1].size()-1]<ziel[i].second){
            nast[i]=ziel[i];
            nast2[i]=i;
        }
        else{
            nast[i].first=ziel[i].first+1;
            nast[i].second=*lower_bound(zielone[ziel[i].first+1].begin(),zielone[ziel[i].first+1].end(),ziel[i].second);
            //cout<<" "<<(int)zielone[ziel[i].first].size()<<"   ";
        
            nast2[i]=mp[{ziel[i].first+1,*lower_bound(zielone[ziel[i].first+1].begin(),zielone[ziel[i].first+1].end(),ziel[i].second)}];
        }
        point[i].push_back(nast2[i]);
        //cout<<"  "<<nast[i].first<<" "<<nast[i].second<<" "<<nast2[i]<<" "<<i<<"    ";
    }
    for(int j=1;j<N+3;j=j<<1){
        for(int i=0;i<N;i++){
            pom[i]= point[  point[i][point[i].size()-1] ]  [point  [ point[i][point[i].size()-1] ]  .size()-1] ;
        
                        
        }
        for(int i=0;i<N+7;i++)
            point[i].push_back(pom[i]);
       // if(j==4)
        //    return 0;
    }
    //cout<<"\n\n\n";
    cin>>T;
    for(int i=0;i<T;i++){
        cin>>a>>b>>c>>d;
        if(a>c){
            cout<<"No\n";
            continue;
        }
        if(c-a>N){
            cout<<"No\n";
            continue;
        }
        if(a==c){
            if(b<=d)
                cout<<"Yes\n";
            else
                cout<<"No\n";
            continue;
        }
        c--;
        if(zielone[a].empty() || zielone[a][zielone[a].size()-1]<b){
            if(a==c+1 && b<=d)
                cout<<"Yes\n";
            else
                cout<<"No\n";
            continue;
        }
        int ak=mp[{a,*lower_bound(zielone[a].begin(),zielone[a].end(),b)}];
        int logarithm=0;
        int ak2=1;
        while(ak2*8<=c-a){
            ak2*=2;
            logarithm++;
        }
        //cout<<ak<<" ";
        while(a!=c){
            ak=point[ak][logarithm];
            a+=ak2;
            while(ak2>c-a){
                ak2/=2;
                logarithm--;
            }
        }
        if((ziel[ak].first==c) && (ziel[ak].second<=d))
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9564 KB 200 token(s): yes count is 21, no count is 179
2 Correct 13 ms 9864 KB 200 token(s): yes count is 70, no count is 130
3 Correct 10 ms 9304 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 439 ms 53440 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 469 ms 53696 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 410 ms 52592 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 481 ms 53696 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 531 ms 58432 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 520 ms 58304 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 585 ms 58600 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 743 ms 59200 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 786 ms 59372 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 962 ms 65412 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9308 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 12 ms 9052 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 12 ms 10072 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 9 ms 9048 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 14 ms 9308 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 10 ms 9052 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 1569 ms 66756 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 1120 ms 61180 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 724 ms 58992 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1687 ms 79572 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 1002 ms 65684 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 756 ms 58300 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 789 ms 58192 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 716 ms 58304 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1421 ms 64916 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1404 ms 64804 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1769 ms 72352 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 536 ms 58044 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 602 ms 58288 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 856 ms 58636 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 641 ms 58132 KB 200000 token(s): yes count is 129674, no count is 70326