답안 #547165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
547165 2022-04-09T18:12:39 Z AlexRex0 최후의 만찬 (IOI12_supper) C++14
0 / 100
361 ms 19152 KB
#include "advisor.h"

void ComputeAdvice(int *C, int N, int K, int M) {
    /// funciona para mandar el numero WriteAdvice();
    int bitsOcupo = 0;
    if(N <= 5000){
        bitsOcupo = 13;
    }else{
        bitsOcupo = 17;
    }
    for(int i = 0; i < N; ++i){
        int num = C[i];
        int bits = 0;
        while(num > 0){
            WriteAdvice(num % 2);
            bits++;
            num/=2;
        }
        for(int j = bits + 1; j <= bitsOcupo; ++j){
            WriteAdvice(0);
        }
    }
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {

    int bitsOcupo = 0;
    if(N <= 5000){
        bitsOcupo = 13;
    }else{
        bitsOcupo = 17;
    }
    int secOriginal[100002];
    /// pongo los que tengo actualmente en el andamio
    int pos = 0;
    for(int i = 1; i <= N; ++i){
        int num = 0;
        int pot = 1;
        for(int j = 1; j <= bitsOcupo; ++j){
            if((int)A[pos] == 1){
                num+= pot;
            }
            //cout << (int)A[pos] << ' ';
            pot*=2;
            pos++;
        }
        secOriginal[i] = num;
    }
    int apariciones[100002];
    int sigAparicion[100002];
    int ultima[100002];
    for(int i = N; i >= 0; --i){
        apariciones[i] = INT_MAX;
        ultima[i] = INT_MAX;
    }
    for(int i = N; i >= 1; --i){
        sigAparicion[i] = apariciones[secOriginal[i]];
        ultima[secOriginal[i]] = sigAparicion[i];
        apariciones[secOriginal[i]] = i;
    }
    /// el first es la posicion de la siguiente aparicion
    /// el second es el color
    priority_queue<pair<int, int> > colaP;
    bool andamio[100002];
    for(int i = 0; i < N; ++i){
        if(i < K){
            andamio[i] = true;
            colaP.push({apariciones[i], ultima[i]});
        }else{
            andamio[i] = false;
        }
    }
    for(int i = 1; i <= N; ++i){
        int sigColor = GetRequest();
        if(!andamio[sigColor]){
            pair<int, int> aux;
            aux = colaP.top();
            colaP.pop();
            PutBack(aux.second);
            andamio[aux.second] = false;
            andamio[sigColor] = true;
            colaP.push({sigAparicion[i], sigColor});
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 3964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 41 ms 5440 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 291 ms 16228 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 344 ms 18960 KB Execution killed with signal 11
2 Runtime error 335 ms 19152 KB Execution killed with signal 11
3 Runtime error 344 ms 19068 KB Execution killed with signal 11
4 Runtime error 341 ms 19052 KB Execution killed with signal 11
5 Runtime error 334 ms 19140 KB Execution killed with signal 11
6 Runtime error 361 ms 19080 KB Execution killed with signal 11
7 Runtime error 341 ms 19108 KB Execution killed with signal 11
8 Runtime error 319 ms 18996 KB Execution killed with signal 11
9 Runtime error 329 ms 19072 KB Execution killed with signal 11
10 Runtime error 331 ms 18964 KB Execution killed with signal 11