답안 #65098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65098 2018-08-06T15:44:30 Z aquablitz11 최후의 만찬 (IOI12_supper) C++14
43 / 100
230 ms 34464 KB
#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;

using pii = pair<int, int>;

static const int N = 100010;
static const int INF = 1e9;

static int ptr[N], last[N], ans[N];
static vector<int> seqpos[N];
static set<pii> S;

static int getnext(int x) {
    if (ptr[x] < (int)seqpos[x].size())
        return seqpos[x][ptr[x]];
    else
        return INF;
}

static void movenext(int x) {
    S.erase(pii(getnext(x), x));
    ++ptr[x];
    S.insert(pii(getnext(x), x));
}

void ComputeAdvice(int *C, int n, int k, int m) {

    for (int i = 0; i < n; ++i)
        seqpos[C[i]].push_back(i);
    for (int i = 0; i < k; ++i)
        S.insert(pii(getnext(i), i)), last[i] = i;

    for (int i = 0; i < n; ++i) {
        int x = C[i];
        if (S.count(pii(getnext(x), x))) {
            //printf("found %d\n", x);
        } else {
            auto it = prev(S.end());
            ans[last[it->second]] = 1;
            //printf("threw away %d\n", it->second);
            S.erase(it);
            S.insert(pii(getnext(x), x));
        }
        movenext(x);
        last[x] = k+i;
    }
    for (int i = 0; i < n+k; ++i)
        WriteAdvice(ans[i]);

}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;

void Assist(unsigned char *A, int n, int k, int r) {

    r = 0;
    set<int> has;
    deque<int> avail;
    for (int i = 0; i < k; ++i) {
        has.insert(i);
        if (A[r++] == 1)
            avail.push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        int x = GetRequest();
        if (!has.count(x)) {
            has.erase(avail.front());
            PutBack(avail.front());
            avail.pop_front();
            has.insert(x);
        }
        if (A[r++] == 1)
            avail.push_back(x);
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5360 KB Output is correct
2 Correct 8 ms 5832 KB Output is correct
3 Correct 9 ms 5848 KB Output is correct
4 Correct 11 ms 6000 KB Output is correct
5 Correct 17 ms 6448 KB Output is correct
6 Correct 17 ms 6520 KB Output is correct
7 Correct 13 ms 6680 KB Output is correct
8 Correct 16 ms 7264 KB Output is correct
9 Correct 22 ms 7264 KB Output is correct
10 Correct 20 ms 7272 KB Output is correct
11 Correct 19 ms 7272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 7880 KB Output is correct
2 Correct 95 ms 11232 KB Output is correct
3 Incorrect 154 ms 20248 KB Error - advice must be 0 or 1
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 230 ms 20248 KB Output is correct
2 Incorrect 153 ms 20248 KB Error - advice must be 0 or 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 20248 KB Output is correct
2 Correct 18 ms 20248 KB Output is correct
3 Correct 15 ms 20248 KB Output is correct
4 Correct 13 ms 20248 KB Output is correct
5 Correct 16 ms 20248 KB Output is correct
6 Correct 16 ms 20248 KB Output is correct
7 Correct 18 ms 20248 KB Output is correct
8 Correct 16 ms 20248 KB Output is correct
9 Correct 19 ms 20248 KB Output is correct
10 Correct 17 ms 20248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 138 ms 21384 KB Error - advice must be 0 or 1
2 Incorrect 152 ms 22728 KB Error - advice must be 0 or 1
3 Incorrect 173 ms 23992 KB Error - advice must be 0 or 1
4 Incorrect 170 ms 25168 KB Error - advice must be 0 or 1
5 Incorrect 151 ms 26680 KB Error - advice must be 0 or 1
6 Incorrect 130 ms 27520 KB Error - advice must be 0 or 1
7 Incorrect 188 ms 28936 KB Error - advice must be 0 or 1
8 Incorrect 162 ms 30096 KB Error - advice must be 0 or 1
9 Incorrect 163 ms 31000 KB Error - advice must be 0 or 1
10 Incorrect 130 ms 34464 KB Error - advice must be 0 or 1