답안 #122177

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122177 2019-06-27T19:00:47 Z Osama_Alkhodairy 최후의 만찬 (IOI12_supper) C++17
0 / 100
2500 ms 7220 KB
#include <bits/stdc++.h>
#include "advisor.h"
//~ #include "grader.cpp"
using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
    vector <int> las(N, N);
    vector <int> nex(N);
    for(int i = N - 1 ; i >= 0 ; i--){
        nex[i] = las[C[i]];
        las[C[i]] = i;
    }
    set <pair <int, int> > ready;
    for(int i = 0 ; i < K ; i++){
        ready.insert(make_pair(las[i], i));
    }
    vector <int> p(N);
    for(int i = 0 ; i < N ; i++){
        if(ready.count(make_pair(i, C[i]))){
            ready.erase(ready.find(make_pair(i, C[i])));
            ready.insert(make_pair(nex[i], C[i]));
            continue;
        }
        ready.erase(--ready.end());
        ready.insert(make_pair(nex[i], C[i]));
        p[i] = 1;
    }
    for(int i = 0 ; i < K ; i++){
        if(las[i] == N) WriteAdvice(1);
        else WriteAdvice(p[las[i]]);
    }
    for(int i = 0 ; i < N ; i++){
        if(nex[i] == N) WriteAdvice(1);
        else WriteAdvice(p[nex[i]]);
    }
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {
    set <int> ready, passive;
    for(int i = 0 ; i < K ; i++){
        if(A[i] == 1) passive.insert(i);
        ready.insert(i);
    }
    for(int i = 0 ; i < N ; i++){
        int x = GetRequest();
        if(ready.count(x) == 0){
            int put = -1;
            for(auto &j : passive){
                if(ready.count(j)){
                    put = j;
                    break;
                }
            }
            assert(put != -1);
            PutBack(put);
            ready.erase(put);
            ready.insert(x);
        }
        if(A[K + i] == 1) passive.insert(x);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 776 KB Output is correct
2 Correct 4 ms 776 KB Output is correct
3 Correct 5 ms 900 KB Output is correct
4 Incorrect 7 ms 920 KB Output isn't correct - not an optimal way
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 398 ms 1624 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2589 ms 5800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1052 KB Output is correct
2 Correct 142 ms 1304 KB Output is correct
3 Incorrect 39 ms 1064 KB Output isn't correct - not an optimal way
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2514 ms 6588 KB Time limit exceeded
2 Execution timed out 2524 ms 6724 KB Time limit exceeded
3 Execution timed out 2530 ms 7128 KB Time limit exceeded
4 Execution timed out 2512 ms 7188 KB Time limit exceeded
5 Execution timed out 2518 ms 7040 KB Time limit exceeded
6 Execution timed out 2525 ms 7088 KB Time limit exceeded
7 Execution timed out 2505 ms 7220 KB Time limit exceeded
8 Execution timed out 2505 ms 7144 KB Time limit exceeded
9 Execution timed out 2534 ms 7020 KB Time limit exceeded
10 Execution timed out 2595 ms 6856 KB Time limit exceeded