답안 #987831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987831 2024-05-23T16:22:38 Z user736482 Trampoline (info1cup20_trampoline) C++17
11 / 100
2000 ms 59284 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];
map<int,vector<int>>zielone;
map<pair<int,int>,int>mp;

int main(){
    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());
    }
    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(),nast[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(),nast[i].second)}];
        }
        point[i].push_back(nast2[i]);
        //cout<<"  "<<nast[i].first<<" "<<nast[i].second<<" "<<nast2[i]<<"    ";
    }
    for(int j=2;j<N+7;j=j<<1){
        for(int i=0;i<N;i++){
            point[i].push_back( point[point[i][point[i].size()-1]][point[point[i][point[i].size()-1]].size()-1] );
        
                        
        }
       // 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;
        }
        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*2<c-a){
            ak2*=2;
            logarithm++;
        }
        //cout<<ak2<<" ";
        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";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 8792 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2035 ms 51516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 953 ms 51276 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 957 ms 51192 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 1033 ms 51572 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 1220 ms 51936 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 1167 ms 51820 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 1630 ms 57828 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2023 ms 8280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2025 ms 59284 KB Time limit exceeded
2 Halted 0 ms 0 KB -