답안 #547177

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
547177 2022-04-09T18:45:02 Z AlexRex0 최후의 만찬 (IOI12_supper) C++14
0 / 100
373 ms 14920 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;

priority_queue<pair<int, int> > colaP;
int apariciones[100002];
int sigAparicion[100002];
int ultima[100002];

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 - 1] = num;
    }
    for(int i = N - 1; i >= 0; --i){
        apariciones[i] = INT_MAX;
        ultima[i] = INT_MAX;
    }
    for(int i = N - 1; i >= 0; --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

    bool andamio[100002];
    for(int i = 0; i < N; ++i){
        if(i < K){
            andamio[i] = true;
            colaP.push({ultima[i], i});
        }else{
            andamio[i] = false;
        }
    }
    for(int i = 0; i < N; ++i){
        int sigColor = GetRequest();
        if(!andamio[sigColor]){
            pair<int, int> aux;
            aux = colaP.top();
            colaP.pop();
            PutBack(aux.second);
            //cout << '\n' << aux.second << '\n';
            andamio[aux.second] = false;
            andamio[sigColor] = true;
            colaP.push({sigAparicion[i], sigColor});
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1020 KB Output is correct
2 Incorrect 1 ms 1028 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 2388 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 266 ms 12108 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 516 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 373 ms 14764 KB Output isn't correct - not an optimal way
2 Incorrect 318 ms 14672 KB Output isn't correct - not an optimal way
3 Incorrect 339 ms 14740 KB Output isn't correct - not an optimal way
4 Incorrect 364 ms 14920 KB Output isn't correct - not an optimal way
5 Incorrect 335 ms 14768 KB Output isn't correct - not an optimal way
6 Incorrect 351 ms 14772 KB Output isn't correct - not an optimal way
7 Incorrect 361 ms 14660 KB Output isn't correct - not an optimal way
8 Incorrect 326 ms 14792 KB Output isn't correct - not an optimal way
9 Incorrect 357 ms 14732 KB Output isn't correct - not an optimal way
10 Incorrect 343 ms 14776 KB Output isn't correct - not an optimal way