답안 #138107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138107 2019-07-29T11:04:44 Z zoooma13 최후의 만찬 (IOI12_supper) C++14
0 / 100
241 ms 17384 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 ,-1);
    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();
        assert(lst[now.second] != -1);
        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:36: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 860 KB Output is correct
2 Runtime error 6 ms 1020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 2288 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 163 ms 14056 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 211 ms 16456 KB Output isn't correct - not an optimal way
2 Incorrect 219 ms 16880 KB Output isn't correct - not an optimal way
3 Incorrect 218 ms 17128 KB Output isn't correct - not an optimal way
4 Incorrect 241 ms 17384 KB Output isn't correct - not an optimal way
5 Incorrect 216 ms 17072 KB Output isn't correct - not an optimal way
6 Incorrect 223 ms 17128 KB Output isn't correct - not an optimal way
7 Incorrect 220 ms 17072 KB Output isn't correct - not an optimal way
8 Incorrect 219 ms 17128 KB Output isn't correct - not an optimal way
9 Incorrect 219 ms 17128 KB Output isn't correct - not an optimal way
10 Correct 227 ms 16872 KB Output is correct - 125000 bits used