Submission #97471

# Submission time Handle Problem Language Result Execution time Memory
97471 2019-02-16T11:11:39 Z Alexa2001 Last supper (IOI12_supper) C++17
0 / 100
123 ms 8672 KB
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 2e5 + 5;

static int nxt[Nmax], last[Nmax], in[Nmax], c[Nmax], scoate[Nmax];
static priority_queue < pair<int,int> > heap;

void ComputeAdvice(int *C, int N, int K, int M)
{
    int i;

    for(i=0; i<N; ++i) last[i] = N;

    for(i=0; i<K; ++i) c[i] = i;
    for(; i<N+K; ++i) c[i] = C[i-K];

    for(i=N-1; i>=0; --i)
    {
        nxt[i] = last[c[i]];
        last[c[i]] = i;
    }

    for(i=0; i<K; ++i)
    {
        in[i] = 1;
        heap.push({ nxt[i], i });
    }

    for(; i<N+K; ++i)
    {
        if(in[c[i]])
        {
            heap.push({ nxt[i], i });
            continue;
        }

        int node = heap.top().second;
        heap.pop();

        in[c[node]] = 0;
        scoate[node] = 1;

        heap.push({ nxt[i], i });
    }

    for(i=0; i<N+K; ++i) WriteAdvice(scoate[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 1e5 + 5;
static int in[Nmax];

void Assist(unsigned char *A, int N, int K, int R)
{
    int i;
    vector<int> active;

    for(i=0; i<K; ++i)
    {
        if(A[i]) active.push_back(i);
        in[i] = 1;
    }

    for(i=0; i<N; ++i)
    {
        int x = GetRequest();
        if(in[x]) continue;

        assert(active.size());

        int y = active.back();
        active.pop_back();

        PutBack(y);
        in[y] = 0;

        in[x] = 1;
        if(A[K+i]) active.push_back(x);
    }

    assert(active.empty());
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 856 KB Output is correct
2 Runtime error 5 ms 1104 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 1740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 75 ms 7136 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1188 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 89 ms 8272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 98 ms 8416 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 107 ms 8672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 92 ms 8568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 101 ms 8112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 93 ms 8160 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 98 ms 8416 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 84 ms 8512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 123 ms 8520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 81 ms 8416 KB Execution killed with signal 11 (could be triggered by violating memory limits)