Submission #97469

# Submission time Handle Problem Language Result Execution time Memory
97469 2019-02-16T11:08:26 Z Alexa2001 Last supper (IOI12_supper) C++17
0 / 100
132 ms 9872 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] = -1;

    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]]) 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 Incorrect 4 ms 852 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 1916 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 66 ms 7928 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 1352 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 120 ms 9448 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 132 ms 9448 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 90 ms 9392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 90 ms 9576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 108 ms 9872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 118 ms 9584 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 86 ms 9448 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 108 ms 9800 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 96 ms 9520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 87 ms 9192 KB Execution killed with signal 11 (could be triggered by violating memory limits)