제출 #1339027

#제출 시각아이디문제언어결과실행 시간메모리
1339027moondarksideTwo Transportations (JOI19_transportations)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

void SendA(bool y);

int baseDistA=0;
vector<int> DistanceA;
vector<priority_queue<pair<int,int>>> EdgesA;
pair<int,int> OPTIM;
int DistTempA=0;
int stateA=0;
int valueA=0;
int transA=0;



pair<int,int> GetClosest(vector<int>& Distance,vector<priority_queue<pair<int,int>>>& Edges){
    pair<int,int> OPT={1000000000,1000000000};
    for(int i=0;i<Distance.size();i++){
        
        if(Distance[i]!=-1){
            
            while(!Edges[i].empty() && Distance[Edges[i].top().second]!=-1){
                Edges[i].pop();
            }
            if(!Edges[i].empty()){
                pair<int,int> SOL={-Edges[i].top().first+Distance[i],Edges[i].top().second};
                OPT=min(OPT,SOL);
            }
            
        }
        
    }
    return OPT;
    
}





void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){
    DistanceA=vector<int>(N,-1);
    EdgesA=vector<priority_queue<pair<int,int>>>(N);
    DistanceA[0]=0;
    for(int i=0;i<A;i++){
        EdgesA[U[i]].push({-C[i],V[i]});
        EdgesA[V[i]].push({-C[i],U[i]});
    }
    OPTIM=GetClosest(DistanceA,EdgesA);
    
    
    
    
}

void ReceiveA(bool x){
    
    if(OPTIM==(pair<int,int>){1000000000,1000000000}){
        return;
    }
    if(stateA==0){
        
        if(x){
            valueA=valueA | (1<<transA);
        }
        
        transA++;
        
        if(transA==9){
            
            auto t=OPTIM;
            
            if(OPTIM.first-baseDistA<valueA){
                
                SendA(false);
                
                for(int i=0;i<9;i++){
                    
                    if(((OPTIM.first-baseDistA) & (1<<i))==0){
                        SendA(false);
                    }
                    else{
                        SendA(true);
                    }
                    
                }
                transA=0;
                valueA=0;
                baseDistA=OPTIM.first;
                DistanceA[OPTIM.second]=OPTIM.first;
                pair<int,int> TOPT=OPTIM;
                OPTIM=GetClosest(DistanceA,EdgesA);
                for(int i=0;i<12;i++){
                    
                    if((TOPT.second & (1<<i))==0){
                        SendA(false);
                    }
                    else{
                        SendA(true);
                    }
                    
                }
                
                
                
                
            }
            else{
                DistTempA=valueA;
                transA=0;
                valueA=0;
                stateA=1;
                SendA(true);
            }
            
            
            
        }
        
        
    }
    else{
        
       if(x){
            valueA=valueA | (1<<transA);
        } 
        transA++;
        if(transA==12){
            
            
            
            DistanceA[valueA]=DistTempA+baseDistA;
            baseDistA+=DistTempA;
            transA=0;
            valueA=0;
            stateA=0;
            OPTIM=GetClosest(DistanceA,EdgesA);
        }
        
    }
}

std::vector<int> Answer(){
    return DistanceA;
}




/*
#include<bits/stdc++.h>
using namespace std;
*/

void SendB(bool y);

vector<int> DistanceB;
vector<priority_queue<pair<int,int>>> EdgesB;
int baseDistB=0;

int stateB=0;
int valueB=0;
int transB=0;
int tempB=0;

pair<int,int> GetClosestB(vector<int>& Distance,vector<priority_queue<pair<int,int>>>& Edges){
    pair<int,int> OPT={1000000000,1000000000};
    for(int i=0;i<Distance.size();i++){
        
        if(Distance[i]!=-1){
            
            while(!Edges[i].empty() && Distance[Edges[i].top().second]!=-1){
                Edges[i].pop();
            }
            if(!Edges[i].empty()){
                pair<int,int> SOL={-Edges[i].top().first+Distance[i],Edges[i].top().second};
                OPT=min(OPT,SOL);
            }
        }
        
    }
    return OPT;
    
}

void InitB(int N, int B, std::vector<int> U, std::vector<int> V, std::vector<int> C){
    DistanceB=vector<int>(N,-1);
    DistanceB[0]=0;
    EdgesB=vector<priority_queue<pair<int,int>>>(N);
    for(int i=0;i<B;i++){
        EdgesB[U[i]].push({-C[i],V[i]});
        EdgesB[V[i]].push({-C[i],U[i]});
    }
    pair<int,int> A=GetClosestB(DistanceB,EdgesB);
    
    for(int i=0;i<9;i++){
        if((A.first & (1<<i))==0){
            SendB(false);
        }
        else{
            SendB(true);
        }
    }
    
}

void ReceiveB(bool x){
    
    if(stateB==0){
        if(x){
            pair<int,int> A=GetClosestB(DistanceB,EdgesB);
            for(int i=0;i<12;i++){
                
                if((A.second & (1<<i))==0){
                    SendB(false);
                }
                else{
                    SendB(true);
                }
                
            }
            baseDistB=A.first;
            DistanceB[A.second]=A.first;
            
            A=GetClosestB(DistanceB,EdgesB);
            
            
            for(int i=0;i<9;i++){
                if(((A.first-baseDistB) & (1<<i))==0){
                    SendB(false);
                }
                else{
                    SendB(true);
                }
            }
            
            
            
        }else{
            stateB=1;
        }
    }
    else if(stateB==1){
        
        if(x){
            valueB=valueB | (1<<transB);
        }
        
        transB++;
        
        if(transB==9){
            tempB=valueB;
            valueB=0;
            transB=0;
            stateB=2;
        }
        
        
    }
    else{
       
       if(x){
            valueB=valueB | (1<<transB);
        }
        
        transB++;
        
        if(transB==12){
            baseDistB+=tempB;
            DistanceB[valueB]=baseDistB;
            valueB=0;
            transB=0;
            stateB=0;
            
            pair<int,int>A=GetClosestB(DistanceB,EdgesB);
            
            for(int i=0;i<9;i++){
                if(((A.first-baseDistB) & (1<<i))==0){
                    SendB(false);
                }
                else{
                    SendB(true);
                }
            }
            
            
        }
        
    }
    
    
}

컴파일 시 표준 에러 (stderr) 메시지

# 2번째 컴파일 단계

Baijan.cpp:8:1: error: 'vector' does not name a type
    8 | vector<int> DistanceB;
      | ^~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
Baijan.cpp:9:8: error: 'priority_queue' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |        ^~~~~~~~~~~~~~
Baijan.cpp:9:23: error: 'pair' was not declared in this scope
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      |                       ^~~~
Baijan.cpp:9:1: error: 'vector' does not name a type
    9 | vector<priority_queue<pair<int,int>>> EdgesB;
      | ^~~~~~
Baijan.cpp:17:1: error: 'pair' does not name a type
   17 | pair<int,int> GetClosestB(vector<int>& Distance,vector<priority_queue<pair<int,int>>>& Edges){
      | ^~~~
Baijan.cpp:37:26: error: 'std::vector' has not been declared
   37 | void InitB(int N, int B, std::vector<int> U, std::vector<int> V, std::vector<int> C){
      |                          ^~~
Baijan.cpp:37:37: error: expected ',' or '...' before '<' token
   37 | void InitB(int N, int B, std::vector<int> U, std::vector<int> V, std::vector<int> C){
      |                                     ^
Baijan.cpp: In function 'void InitB(int, int, int)':
Baijan.cpp:38:5: error: 'DistanceB' was not declared in this scope
   38 |     DistanceB=vector<int>(N,-1);
      |     ^~~~~~~~~
Baijan.cpp:38:15: error: 'vector' was not declared in this scope
   38 |     DistanceB=vector<int>(N,-1);
      |               ^~~~~~~~~~~
Baijan.cpp:40:5: error: 'EdgesB' was not declared in this scope
   40 |     EdgesB=vector<priority_queue<pair<int,int>>>(N);
      |     ^~~~~~
Baijan.cpp:40:34: error: 'pair' was not declared in this scope
   40 |     EdgesB=vector<priority_queue<pair<int,int>>>(N);
      |                                  ^~~~
Baijan.cpp:40:19: error: 'priority_queue' was not declared in this scope
   40 |     EdgesB=vector<priority_queue<pair<int,int>>>(N);
      |                   ^~~~~~~~~~~~~~
Baijan.cpp:40:39: error: expected primary-expression before 'int'
   40 |     EdgesB=vector<priority_queue<pair<int,int>>>(N);
      |                                       ^~~
Baijan.cpp:42:16: error: 'U' was not declared in this scope
   42 |         EdgesB[U[i]].push({-C[i],V[i]});
      |                ^
Baijan.cpp:42:29: error: 'C' was not declared in this scope
   42 |         EdgesB[U[i]].push({-C[i],V[i]});
      |                             ^
Baijan.cpp:42:34: error: 'V' was not declared in this scope
   42 |         EdgesB[U[i]].push({-C[i],V[i]});
      |                                  ^
Baijan.cpp:45:10: error: expected primary-expression before 'int'
   45 |     pair<int,int> A=GetClosestB(DistanceB,EdgesB);
      |          ^~~
Baijan.cpp:48:13: error: 'A' was not declared in this scope
   48 |         if((A.first & (1<<i))==0){
      |             ^
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:62:13: error: 'pair' was not declared in this scope
   62 |             pair<int,int> A=GetClosestB(DistanceB,EdgesB);
      |             ^~~~
Baijan.cpp:62:18: error: expected primary-expression before 'int'
   62 |             pair<int,int> A=GetClosestB(DistanceB,EdgesB);
      |                  ^~~
Baijan.cpp:65:21: error: 'A' was not declared in this scope
   65 |                 if((A.second & (1<<i))==0){
      |                     ^
Baijan.cpp:73:23: error: 'A' was not declared in this scope
   73 |             baseDistB=A.first;
      |                       ^
Baijan.cpp:74:13: error: 'DistanceB' was not declared in this scope
   74 |             DistanceB[A.second]=A.first;
      |             ^~~~~~~~~
Baijan.cpp:76:37: error: 'EdgesB' was not declared in this scope
   76 |             A=GetClosestB(DistanceB,EdgesB);
      |                                     ^~~~~~
Baijan.cpp:76:15: error: 'GetClosestB' was not declared in this scope
   76 |             A=GetClosestB(DistanceB,EdgesB);
      |               ^~~~~~~~~~~
Baijan.cpp:121:13: error: 'DistanceB' was not declared in this scope
  121 |             DistanceB[valueB]=baseDistB;
      |             ^~~~~~~~~
Baijan.cpp:126:13: error: 'pair' was not declared in this scope
  126 |             pair<int,int>A=GetClosestB(DistanceB,EdgesB);
      |             ^~~~
Baijan.cpp:126:18: error: expected primary-expression before 'int'
  126 |             pair<int,int>A=GetClosestB(DistanceB,EdgesB);
      |                  ^~~
Baijan.cpp:129:22: error: 'A' was not declared in this scope
  129 |                 if(((A.first-baseDistB) & (1<<i))==0){
      |                      ^