답안 #871697

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871697 2023-11-11T10:37:40 Z Matjaz 최후의 만찬 (IOI12_supper) C++14
43 / 100
2500 ms 136940 KB
#include "advisor.h"

#include<set>
#include<queue>
#include<vector>

using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
    
    set<int> scafold;
    for (int i=0;i<K;i++) scafold.insert(i);
    
    vector<queue<int> > Q(N);
    vector<queue<int> > returns(N);
    for (int i=0;i<N;i++) Q[C[i]].push(i);
    for (int i=0;i<N;i++) Q[i].push(N);
    vector<int> takeback(N, -1);
    
    for (int i=0;i<N;i++){
        Q[C[i]].pop();
        if (scafold.count(C[i]) > 0) continue;
            
        int besttime = -1;
        int bestcolour = -1;
            
        for (set<int>::iterator it = scafold.begin(); it != scafold.end(); it++){
                
            int u = *it;
            if (Q[u].empty() || Q[u].front() > besttime){
                besttime = Q[u].empty() ? N : Q[u].front();
                bestcolour = u;
            }
            
        }
        scafold.erase(bestcolour);
        scafold.insert(C[i]);
        returns[bestcolour].push(i);
        takeback[i] = bestcolour;
    }

    Q.assign(N, queue<int> ());
    for (int i=0;i<N;i++) Q[C[i]].push(i);
    for (int i=0;i<N;i++) Q[i].push(N);

    for (int i=0;i<K;i++){
        if (Q[i].empty()){
            WriteAdvice(0);
            continue;
        }
        
        if (returns[i].empty()){
            WriteAdvice(1);
            continue;
        }
            
        if (Q[i].front() <= returns[i].front()){
            WriteAdvice(1);
        } else WriteAdvice(0);

    }
    
        
    for (int i=0;i<N;i++){
        Q[C[i]].pop();
        if (Q[C[i]].empty()){
            WriteAdvice(0);
            continue;
        }
        if (returns[C[i]].empty()){
            WriteAdvice(1);
            continue;
        }

        if (Q[C[i]].front() <= returns[C[i]].front()){
            WriteAdvice(1);
        } else WriteAdvice(0);

        if (takeback[i] != -1) returns[takeback[i]].pop();
    }
    
}
#include "assistant.h"


#include<queue>
#include<set>
#include<assert.h>

using namespace std;




void Assist(unsigned char *A, int N, int K, int R) {
    
    set<int> expendable,scafold;
    for (int i=0;i<K;i++) if (A[i] == 0) expendable.insert(i);
    for (int i=0;i<K;i++) scafold.insert(i);
    
    for (int i=0;i<N;i++){
        int req = GetRequest();
        
        if (scafold.count(req) > 0){
            if (A[K + i] == 0) expendable.insert(req);
            continue;
        }
        assert(expendable.size() > 0);
        PutBack(*expendable.begin());
        scafold.erase(*expendable.begin());
        expendable.erase(*expendable.begin());
        scafold.insert(req);
        if (A[K + i] == 0) expendable.insert(req);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 792 KB Output is correct
2 Correct 0 ms 780 KB Output is correct
3 Correct 1 ms 2068 KB Output is correct
4 Correct 5 ms 4916 KB Output is correct
5 Correct 6 ms 7628 KB Output is correct
6 Correct 10 ms 7784 KB Output is correct
7 Correct 7 ms 7784 KB Output is correct
8 Correct 28 ms 7952 KB Output is correct
9 Correct 26 ms 7784 KB Output is correct
10 Correct 41 ms 7772 KB Output is correct
11 Correct 26 ms 7776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 14844 KB Output is correct
2 Incorrect 1242 ms 70788 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2553 ms 110132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6372 KB Output is correct
2 Correct 33 ms 7776 KB Output is correct
3 Correct 7 ms 7784 KB Output is correct
4 Correct 6 ms 7532 KB Output is correct
5 Correct 8 ms 7524 KB Output is correct
6 Correct 10 ms 7520 KB Output is correct
7 Correct 20 ms 7780 KB Output is correct
8 Correct 23 ms 8008 KB Output is correct
9 Correct 31 ms 7792 KB Output is correct
10 Correct 28 ms 8020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2517 ms 136784 KB Time limit exceeded
2 Execution timed out 2564 ms 136788 KB Time limit exceeded
3 Execution timed out 2529 ms 136836 KB Time limit exceeded
4 Execution timed out 2556 ms 136940 KB Time limit exceeded
5 Execution timed out 2544 ms 136788 KB Time limit exceeded
6 Execution timed out 2528 ms 136880 KB Time limit exceeded
7 Execution timed out 2542 ms 136796 KB Time limit exceeded
8 Execution timed out 2548 ms 136788 KB Time limit exceeded
9 Execution timed out 2514 ms 136784 KB Time limit exceeded
10 Execution timed out 2534 ms 136784 KB Time limit exceeded