답안 #122191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122191 2019-06-27T19:43:55 Z Osama_Alkhodairy 최후의 만찬 (IOI12_supper) C++17
43 / 100
2500 ms 8244 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;
    }
    int optimal = 0;
    for(auto &i : p) optimal += i;
    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) {
    int pulls = 0;
    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);
            pulls++;
            ready.erase(put);
            ready.insert(x);
        }
        if(A[K + i] == 1) passive.insert(x);
        else passive.erase(x);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 776 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 5 ms 900 KB Output is correct
4 Correct 7 ms 984 KB Output is correct
5 Correct 54 ms 1056 KB Output is correct
6 Correct 114 ms 1212 KB Output is correct
7 Correct 12 ms 1160 KB Output is correct
8 Correct 133 ms 1240 KB Output is correct
9 Correct 147 ms 1312 KB Output is correct
10 Correct 66 ms 1180 KB Output is correct
11 Correct 87 ms 1316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 407 ms 1512 KB Output is correct
2 Execution timed out 2566 ms 3900 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2513 ms 6484 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1300 KB Output is correct
2 Correct 138 ms 1176 KB Output is correct
3 Correct 39 ms 928 KB Output is correct
4 Correct 65 ms 1056 KB Output is correct
5 Correct 96 ms 928 KB Output is correct
6 Correct 109 ms 1052 KB Output is correct
7 Correct 108 ms 1176 KB Output is correct
8 Correct 90 ms 1384 KB Output is correct
9 Correct 86 ms 1268 KB Output is correct
10 Correct 19 ms 1644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2589 ms 7744 KB Time limit exceeded
2 Execution timed out 2520 ms 7748 KB Time limit exceeded
3 Execution timed out 2519 ms 8244 KB Time limit exceeded
4 Execution timed out 2517 ms 8108 KB Time limit exceeded
5 Execution timed out 2598 ms 8076 KB Time limit exceeded
6 Execution timed out 2512 ms 8128 KB Time limit exceeded
7 Execution timed out 2522 ms 8244 KB Time limit exceeded
8 Execution timed out 2516 ms 8228 KB Time limit exceeded
9 Execution timed out 2518 ms 8004 KB Time limit exceeded
10 Execution timed out 2526 ms 7956 KB Time limit exceeded