답안 #871694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871694 2023-11-11T10:29:55 Z Matjaz 최후의 만찬 (IOI12_supper) C++14
0 / 100
2500 ms 136924 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;
    }
    
    for (int i=0;i<N;i++) while (!Q[i].empty()) Q[i].pop();
    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);

        returns[takeback[i]].pop();
    }
    
}
#include "assistant.h"


#include<queue>
#include<set>

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;
        }
        
        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 780 KB Output is correct
2 Correct 0 ms 784 KB Output is correct
3 Correct 1 ms 2184 KB Output is correct
4 Runtime error 6 ms 8680 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 92 ms 27988 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2563 ms 110164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 11608 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2551 ms 136532 KB Time limit exceeded
2 Execution timed out 2533 ms 136744 KB Time limit exceeded
3 Execution timed out 2515 ms 136788 KB Time limit exceeded
4 Execution timed out 2540 ms 136924 KB Time limit exceeded
5 Execution timed out 2563 ms 136768 KB Time limit exceeded
6 Execution timed out 2520 ms 136788 KB Time limit exceeded
7 Execution timed out 2544 ms 136532 KB Time limit exceeded
8 Execution timed out 2552 ms 136824 KB Time limit exceeded
9 Execution timed out 2554 ms 136904 KB Time limit exceeded
10 Execution timed out 2572 ms 136788 KB Time limit exceeded