답안 #288194

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288194 2020-09-01T09:51:02 Z 2qbingxuan 최후의 만찬 (IOI12_supper) C++14
0 / 100
24 ms 3580 KB
#include "advisor.h"
#include <bits/stdc++.h>
#ifdef local
#define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__)
template <typename H, typename ...T>
void qqbx(const char *s, const H& h, T &&...args) {
    for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
    std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
    if constexpr(sizeof...(T)) qqbx(++s, args...);
}
#define safe \
    std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local

using namespace std;
typedef pair<int,int> pii;

void ComputeAdvice(int *C, int n, int k, int m) {
    int L = __lg(n-1)+1;
    debug(L);
    auto W = [&](int x) -> void {
        for(int i = 0; i < L; i++) {
            WriteAdvice(x & 1);
            x >>= 1;
        }
    };
    vector<bool> ok(n);
    for(int i = 0; i < k; i++) ok[i] = true;
    vector<int> nxt(n), last(n, n);
    for(int i = n-1; i >= 0; i--) {
        nxt[i] = last[C[i]];
        last[C[i]] = i;
    }
    priority_queue<pii> pq;
    for(int i = 0; i < k; i++) pq.push({last[i], i});
    for(int i = 0; i < n; i++) {
        int r = C[i];
        if(!ok[r]) {
            int x = pq.top().second; pq.pop();
            W(x);
            ok[x] = false;
            ok[r] = true;
            assert(C[nxt[i]] == r);
            pq.push({nxt[i], r});
        }
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
#ifdef local
#define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__)
template <typename H, typename ...T>
void qqbx(const char *s, const H& h, T &&...args) {
    for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
    std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
    if constexpr(sizeof...(T)) qqbx(++s, args...);
}
#define safe \
    std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local

using namespace std;

void Assist(unsigned char *A, int n, int k, int len) {
    int L = __lg(n-1)+1;
    int p = 0;
    auto nextint = [&]() -> int {
        int res = 0;
        for(int i = 0; i < L; i++) {
            int c = A[p++];
            assert(c == 0 || c == 1);
            res |= c << i;
        }
        return res;
    };
    vector<bool> ok(n);
    for(int i = 0; i < k; i++) ok[i] = true;
    for(int i = 0; i < n; i++) {
        int r = GetRequest();
        if(!ok[r]) {
            int x = nextint();
            PutBack(x);
            ok[x] = false;
            ok[r] = true;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 2972 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 3444 KB Execution killed with signal 11
2 Runtime error 19 ms 3548 KB Execution killed with signal 11
3 Runtime error 24 ms 3580 KB Execution killed with signal 11
4 Runtime error 20 ms 3580 KB Execution killed with signal 11
5 Runtime error 20 ms 3572 KB Execution killed with signal 11
6 Runtime error 22 ms 3580 KB Execution killed with signal 11
7 Runtime error 21 ms 3580 KB Execution killed with signal 11
8 Runtime error 21 ms 3580 KB Execution killed with signal 11
9 Runtime error 20 ms 3572 KB Execution killed with signal 11
10 Runtime error 20 ms 3580 KB Execution killed with signal 11