Submission #579734

# Submission time Handle Problem Language Result Execution time Memory
579734 2022-06-19T17:32:33 Z Deepesson Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
void WriteAdvice(unsigned char a);
#define MAX 505000
bool conselho[MAX];
int local[MAX],menciona[MAX];
typedef std::pair<int,int> pii;
void ComputeAdvice(int *C, int N, int K, int M) {
   // std::cout<<"Show"<<std::endl;
    std::map<int,std::deque<int>> mapa;
    for(int i=0;i!=N;++i){
        mapa[C[i]].push_back(i);
    }
    for(auto&x:local)x=-1;
    std::priority_queue<pii> queue;
    for(int i=0;i!=K;++i){
        int x=1e9;
        if(mapa[i].size())x=mapa[i].front();
        queue.push({x,i});
        local[i]=x;
        menciona[i]=i;
    }
   // std::cout<<"blz"<<std::endl;
    ///Menciona -> Guarda a cordenada da instrucao q menciona
    ///Local -> Diz o proximo valor da queue
    for(int i=0;i!=N;++i){
        int quer = C[i];
        ///A cor esta no andaime
        if(local[quer]!=-1){
            ///Registra que tem que manter a cor do cara anterior
            conselho[menciona[quer]]=1;
            ///Anda com a cor atual
            mapa[quer].pop_front();
            ///Pega a proxima cor atual
            int x=1e9;
            if(mapa[quer].size())x=mapa[i].front();
            ///Joga na queue
            queue.push({x,i});
            ///Atualiza o local
            local[quer]=x;
            ///Gera a cord
            menciona[quer]=i+K;
            continue;
        }

        ///Procurar cor mais distante
        int cord = -1;
        while(queue.size()){
            auto __ = queue.top();
            queue.pop();
            if(__.first!=local[__.second])continue;
            cord=__.second;
            break;
        }

        ///Anda com a cor atual
        mapa[quer].pop_front();
        ///Pega a proxima cor atual
        int x=1e9;
        if(mapa[quer].size())x=mapa[i].front();
        ///Joga na queue
        queue.push({x,i});
        ///Atualiza o local
        local[quer]=x;
        ///Zera a cord (nao existe mais)
        local[cord]=-1;
        ///Gera a cord
        menciona[quer]=i+K;
    }
   // std::cout<<"Ok envia:"<<std::endl;
    for(int i=0;i!=N+K;++i){
      //      std::cout<<" "<<conselho[i]<<" ";
        WriteAdvice(conselho[i]);
    }
   // std::cout<<std::endl;
}
/* For the player */
int GetRequest();
void PutBack(int T);

void Assist(unsigned char *A, int N, int K, int R) {
    std::map<int,int> paleta;
    std::vector<int> lixo;
    for(int i=0;i!=K;++i){
        paleta[i]=i+1;
        if(!A[i])lixo.push_back(i);
    }
   // std::cout<<"Ok recebe:"<<std::endl;
    for(int i=0;i!=N+K;++i){
          //  std::cout<<" "<<(int)A[i]<<" ";
    }
  //  std::cout<<std::endl;
    for(int i=0;i!=N;++i){
        int x = GetRequest();
       // std::cout<<"Recebe "<<x<<" "<<(int)A[i+K]<<std::endl;
        if(paleta[x]){
           // std::cout<<"Ja tem :)"<<std::endl;
            if(!(A[i+K])){
                lixo.push_back(paleta[x]-1);
                paleta[x]=0;
            }
        }else {
            int b = lixo.back();
            lixo.pop_back();
            PutBack(b);
            if(A[i+K])
            paleta[x]=b+1;
            else lixo.push_back(x);
        }
    }
}

Compilation message

advisor.cpp:5:14: error: 'pair' in namespace 'std' does not name a template type
    5 | typedef std::pair<int,int> pii;
      |              ^~~~
advisor.cpp:1:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
  +++ |+#include <utility>
    1 | void WriteAdvice(unsigned char a);
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:8:10: error: 'map' is not a member of 'std'
    8 |     std::map<int,std::deque<int>> mapa;
      |          ^~~
advisor.cpp:1:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
  +++ |+#include <map>
    1 | void WriteAdvice(unsigned char a);
advisor.cpp:8:14: error: expected primary-expression before 'int'
    8 |     std::map<int,std::deque<int>> mapa;
      |              ^~~
advisor.cpp:10:9: error: 'mapa' was not declared in this scope
   10 |         mapa[C[i]].push_back(i);
      |         ^~~~
advisor.cpp:13:10: error: 'priority_queue' is not a member of 'std'
   13 |     std::priority_queue<pii> queue;
      |          ^~~~~~~~~~~~~~
advisor.cpp:1:1: note: 'std::priority_queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
  +++ |+#include <queue>
    1 | void WriteAdvice(unsigned char a);
advisor.cpp:13:25: error: 'pii' was not declared in this scope
   13 |     std::priority_queue<pii> queue;
      |                         ^~~
advisor.cpp:13:30: error: 'queue' was not declared in this scope
   13 |     std::priority_queue<pii> queue;
      |                              ^~~~~
advisor.cpp:16:12: error: 'mapa' was not declared in this scope
   16 |         if(mapa[i].size())x=mapa[i].front();
      |            ^~~~
advisor.cpp:31:13: error: 'mapa' was not declared in this scope
   31 |             mapa[quer].pop_front();
      |             ^~~~
advisor.cpp:55:9: error: 'mapa' was not declared in this scope
   55 |         mapa[quer].pop_front();
      |         ^~~~

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:6:10: error: 'map' is not a member of 'std'
    6 |     std::map<int,int> paleta;
      |          ^~~
assistant.cpp:1:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
  +++ |+#include <map>
    1 | /* For the player */
assistant.cpp:6:14: error: expected primary-expression before 'int'
    6 |     std::map<int,int> paleta;
      |              ^~~
assistant.cpp:7:10: error: 'vector' is not a member of 'std'
    7 |     std::vector<int> lixo;
      |          ^~~~~~
assistant.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | /* For the player */
assistant.cpp:7:17: error: expected primary-expression before 'int'
    7 |     std::vector<int> lixo;
      |                 ^~~
assistant.cpp:9:9: error: 'paleta' was not declared in this scope
    9 |         paleta[i]=i+1;
      |         ^~~~~~
assistant.cpp:10:18: error: 'lixo' was not declared in this scope
   10 |         if(!A[i])lixo.push_back(i);
      |                  ^~~~
assistant.cpp:20:12: error: 'paleta' was not declared in this scope
   20 |         if(paleta[x]){
      |            ^~~~~~
assistant.cpp:23:17: error: 'lixo' was not declared in this scope
   23 |                 lixo.push_back(paleta[x]-1);
      |                 ^~~~
assistant.cpp:27:21: error: 'lixo' was not declared in this scope
   27 |             int b = lixo.back();
      |                     ^~~~