답안 #579737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579737 2022-06-19T17:36:34 Z Deepesson 최후의 만찬 (IOI12_supper) C++17
0 / 100
324 ms 81524 KB
/* For the advisor */
#include <bits/stdc++.h>

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 */
#include <bits/stdc++.h>

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]=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(x);
            }
        }else {
            int b = lixo.back();
            lixo.pop_back();
            PutBack(b);
            paleta[b]=0;
            if(A[i+K])
            paleta[x]=1;
            else lixo.push_back(x);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2568 KB Output is correct
2 Incorrect 1 ms 2576 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 8796 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 211 ms 53492 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 5152 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 267 ms 65300 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 301 ms 65492 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 280 ms 66116 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 299 ms 66068 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 272 ms 66200 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 305 ms 66072 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 278 ms 66152 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 315 ms 66140 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 276 ms 66116 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 324 ms 81524 KB Output isn't correct - not an optimal way