답안 #361920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
361920 2021-02-01T07:00:32 Z benedict0724 최후의 만찬 (IOI12_supper) C++17
0 / 100
23 ms 8960 KB
#include "advisor.h"
#include <deque>
#include <queue>
using namespace std;

deque<int> useWhen[5000];
queue<int> ret;
int shelf[5000];

void ComputeAdvice(int *C, int N, int K, int M) {
    int logN = 0;
    while(N + 1 <= (1<<logN)) logN++;

    for(int i=0;i<K;i++){
        shelf[i] = i;
    }

    for(int i=0;i<N;i++){
        useWhen[C[i]].push_back(i);
    }

    for(int i=0;i<N;i++){
        bool flag = false;
        for(int j=0;j<K;j++){
            if(shelf[j] == C[i]) flag = true;
        }
        if(!flag){
            int m = 0;
            for(int j=0;j<K;j++){
                while(useWhen[shelf[j]].front() < i) useWhen[shelf[j]].pop_front();
                if(useWhen[shelf[m]].front() < useWhen[shelf[j]].front()) m = j;
            }

            shelf[m] = C[i];
            ret.push(C[i]);
        }
        else{
            ret.push((1<<logN) - 1);
        }
    }

    while(!ret.empty()){
        int now = ret.front(); ret.pop();
        for(int i=0;i<logN;i++){
            if((1<<i) & now) WriteAdvice(1);
            else WriteAdvice(0);
        }
    }
}
#include "assistant.h"

void Assist(unsigned char *A, int N, int K, int R) {
    int i, logN = 0;
    while(N + 1 <= (1<<logN)) logN++;
    for (i = 0; i < N; i++) {
        int req = GetRequest();
        int ans = 0;
        for(int j = 0;j<logN;j++){
            ans *= 2;
            ans += A[i*logN + j] - '0';
        }

        if(ans != (1<<logN) - 1) PutBack(ans);
    }
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:8:13: warning: unused variable 'req' [-Wunused-variable]
    8 |         int req = GetRequest();
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 7276 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 7532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 18 ms 8428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 7276 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 21 ms 8684 KB Execution killed with signal 11
2 Runtime error 21 ms 8684 KB Execution killed with signal 11
3 Runtime error 22 ms 8684 KB Execution killed with signal 11
4 Runtime error 22 ms 8684 KB Execution killed with signal 11
5 Runtime error 23 ms 8960 KB Execution killed with signal 11
6 Runtime error 21 ms 8684 KB Execution killed with signal 11
7 Runtime error 21 ms 8684 KB Execution killed with signal 11
8 Runtime error 21 ms 8684 KB Execution killed with signal 11
9 Runtime error 21 ms 8684 KB Execution killed with signal 11
10 Runtime error 21 ms 8684 KB Execution killed with signal 11