Submission #1083128

# Submission time Handle Problem Language Result Execution time Memory
1083128 2024-09-02T15:55:13 Z codefox Last supper (IOI12_supper) C++14
0 / 100
70 ms 9028 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;
#define pii pair<int, int>

void ComputeAdvice(int *C, int N, int K, int M)
{
    int H = K+N;
    vector<int> next(H, 0);
    vector<int> last(N, 1e9);
    for (int i = N-1; i >= 0; i--)
    {
        next[i+K] = last[C[i]];
        last[C[i]]=i+K;
    }
    for (int i = 0; i < K; i++)
    {
        next[i] = last[i];
    }
    set<pii> follow;
    vector<int> first(N, -1);
    vector<int> ins(N, 0);
    vector<int> del(N+K, 0);

    vector<int> CC(H);
    for (int i = 0; i < K; i++) CC[i] = i;
    for (int i = 0; i < N; i++) CC[i+K] = C[i];

    for (int i = 0; i < K; i++)
    {
        first[i] = i;
        follow.insert({next[i], i});
        ins[i] = 1;
    }
    for (int i = K; i < H; i++)
    {
        if (ins[CC[i]])
        {
            follow.erase({i, first[CC[i]]});
            follow.insert({next[CC[i]], i});
            continue;
        }
        else
        {
            pii ab = *(--follow.end());
            follow.erase(ab);
            ins[CC[ab.second]] = 0;
            del[ab.second] = 1;
            ins[CC[i]] = 1;
            follow.insert({next[CC[i]], i});
        }
        first[CC[i]] = i;
    }
    for (int i = 0; i < H; i++)
    {
        WriteAdvice(del[i]);
    }
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

void Assist(unsigned char *A, int N, int K, int R)
{
    queue<int> del;
    vector<int> ins(N, 0);
    for (int i = 0; i < K; i++)
    {
        ins[i] = 1;
        if (A[i]) del.push(i);
    }
    for (int i = K; i < N+K; i++)
    {
        int g = GetRequest();
        if (!ins[g])
        {
            if (del.empty()) return;
            ins[del.front()]=0;
            ins[g] = 1;
            PutBack(del.front());
            del.pop();
        }
        if (A[i]) del.push(g);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 792 KB Output is correct
2 Incorrect 1 ms 784 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1516 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 7288 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1084 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 8500 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 57 ms 8516 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 56 ms 8784 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 62 ms 8768 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 68 ms 9028 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 60 ms 8936 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 65 ms 8768 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 65 ms 8728 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 65 ms 8964 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 52 ms 8044 KB Output isn't correct - not an optimal way