답안 #138099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138099 2019-07-29T10:43:05 Z zoooma13 최후의 만찬 (IOI12_supper) C++14
0 / 100
253 ms 17640 KB
#include "bits/stdc++.h"
#include "advisor.h"
using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
    vector <vector<int>> occ(N);
    for(int i=0; i<N; i++)
        occ[i].push_back(1e9);
    for(int i=N-1; ~i; i--)
        occ[C[i]].push_back(i);

    priority_queue <pair<int ,int>> pq;
    set <int> shelf;
    for(int i=0; i<K; i++){
        pq.push({occ[i].back() ,i});
        shelf.insert(i);
    }

    vector <bool> seq(N+K ,1);
    vector <int> lst(N);
    iota(lst.begin() ,lst.begin()+K ,0);
    for(int i=0; i<N; i++){
        if(shelf.count(C[i]))
            continue;

        auto now = pq.top(); pq.pop();
        shelf.erase(now.second);
        seq[lst[now.second]] = 0;
        shelf.insert(C[i]);
        occ[C[i]].pop_back();
        pq.push({occ[C[i]].back() ,C[i]});
        lst[C[i]] = K+i;
    }

    for(int i=0; i<seq.size(); i++)
        WriteAdvice(seq[i]);
}
#include "bits/stdc++.h"
#include "assistant.h"
using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {
    vector <bool> seq(R);
    for(int i=0; i<R; i++)
        seq[i] = A[i];

    vector <int> can_remove;
    set <int> shelf;
    for(int i=0; i<K; i++){
        if(!seq[i])
            can_remove.push_back(i);
        shelf.insert(i);
    }

    for(int i=K; i<R; i++){
        int now = GetRequest();
        if(!shelf.count(now)){
            PutBack(can_remove.back());
            shelf.erase(can_remove.back());
            can_remove.pop_back();
            shelf.insert(now);
        }
        if(!seq[i])
            can_remove.push_back(now);
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<seq.size(); i++)
                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 892 KB Output is correct
2 Runtime error 6 ms 1124 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 2544 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 179 ms 14032 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1328 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 234 ms 16840 KB Output isn't correct - not an optimal way
2 Incorrect 227 ms 17128 KB Output isn't correct - not an optimal way
3 Incorrect 213 ms 17640 KB Output isn't correct - not an optimal way
4 Incorrect 215 ms 17472 KB Output isn't correct - not an optimal way
5 Incorrect 211 ms 17432 KB Output isn't correct - not an optimal way
6 Incorrect 218 ms 17384 KB Output isn't correct - not an optimal way
7 Incorrect 220 ms 17384 KB Output isn't correct - not an optimal way
8 Incorrect 253 ms 17640 KB Output isn't correct - not an optimal way
9 Incorrect 248 ms 17640 KB Output isn't correct - not an optimal way
10 Correct 218 ms 17384 KB Output is correct - 125000 bits used