Submission #258745

# Submission time Handle Problem Language Result Execution time Memory
258745 2020-08-06T13:30:55 Z SamAnd Last supper (IOI12_supper) C++17
0 / 100
367 ms 17216 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
const int MAXN = 100005;

void ComputeAdvice(int *C, int N, int K, int M)
{
    int h[MAXN] = {};
    int u[MAXN] = {};
    int d[MAXN] = {};
    int ans[MAXN] = {};

    for (int i = 0; i < N; ++i)
        u[i] = N;
    for (int i = N - 1; i >= 0; --i)
    {
        h[i] = u[C[i]];
        u[C[i]] = i;
    }

    set<int> s;
    for (int i = 0; i < K; ++i)
        s.insert(i);
    set<pair<int, int> > ss;
    for (int i = 0; i < K; ++i)
        ss.insert(m_p(u[i], i));
    for (int i = 0; i < K; ++i)
        d[i] = i + 1;
    for (int i = 0; i < N; ++i)
    {
        if (s.find(C[i]) != s.end())
        {
            continue;
        }
        int x = (--ss.end())->se;
        ss.erase((--ss.end()));
        ss.insert(m_p(h[i], C[i]));
        s.erase(x);
        s.insert(C[i]);
        ans[i] = d[x];
        d[C[i]] = d[x];
    }

    int l = 0;
    while ((1 << l) < K)
        ++l;
    for (int i = 0; i < N; ++i)
    {
        if (ans[i] == 0)
            continue;
        --ans[i];
        for (int j = 0; j < l; ++j)
        {
            if ((ans[i] & (1 << j)))
                WriteAdvice(1);
            else
                WriteAdvice(0);
        }
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

void Assist(unsigned char *A, int N, int K, int R)
{
    int d[N] = {};

    int l = 0;
    while ((1 << l) < K)
        ++l;

    for (int i = 0; i < K; ++i)
        d[i] = i;
    set<int> s;
    for (int i = 0; i < K; ++i)
        s.insert(i);

    int j = 0;
    for (int i = 0; i < N; ++i)
    {
        int x = GetRequest();
        if (s.find(x) != s.end())
            continue;
        int ans = 0;
        for (int ii = 0; ii < l; ++ii, ++j)
        {
            if (A[j])
                ans |= (1 << ii);
        }
        PutBack(d[ans]);
        s.erase(d[ans]);
        d[ans] = x;
        s.insert(d[ans]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3840 KB Output is correct
2 Incorrect 1 ms 3840 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 4864 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 272 ms 13512 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4096 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 345 ms 15600 KB Output isn't correct - not an optimal way
2 Incorrect 367 ms 15600 KB Output isn't correct - not an optimal way
3 Incorrect 341 ms 15856 KB Output isn't correct - not an optimal way
4 Incorrect 321 ms 15856 KB Output isn't correct - not an optimal way
5 Incorrect 326 ms 16120 KB Output isn't correct - not an optimal way
6 Incorrect 327 ms 15856 KB Output isn't correct - not an optimal way
7 Incorrect 346 ms 15856 KB Output isn't correct - not an optimal way
8 Incorrect 334 ms 15856 KB Output isn't correct - not an optimal way
9 Incorrect 328 ms 15856 KB Output isn't correct - not an optimal way
10 Correct 350 ms 17216 KB Output is partially correct - 1117620 bits used