Submission #258755

# Submission time Handle Problem Language Result Execution time Memory
258755 2020-08-06T14:00:45 Z SamAnd Last supper (IOI12_supper) C++17
43 / 100
407 ms 19184 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())
        {
            ss.erase(m_p(i, C[i]));
            ss.insert(m_p(h[i], C[i]));
            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 MAXN = 100005;

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

    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 2 ms 3840 KB Output is correct
2 Correct 2 ms 3840 KB Output is correct
3 Correct 3 ms 3840 KB Output is correct
4 Correct 6 ms 3840 KB Output is correct
5 Correct 5 ms 3840 KB Output is correct
6 Correct 12 ms 4096 KB Output is correct
7 Correct 7 ms 4096 KB Output is correct
8 Correct 14 ms 4352 KB Output is correct
9 Correct 16 ms 4352 KB Output is correct
10 Correct 13 ms 4352 KB Output is correct
11 Correct 13 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 4864 KB Output is correct
2 Correct 119 ms 7664 KB Output is correct
3 Correct 367 ms 19184 KB Output is correct
4 Correct 211 ms 10480 KB Output is correct
5 Correct 295 ms 12528 KB Output is correct
6 Correct 334 ms 13552 KB Output is correct
7 Correct 325 ms 15344 KB Output is correct
8 Correct 307 ms 16368 KB Output is correct
9 Correct 152 ms 9200 KB Output is correct
10 Correct 311 ms 16368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 246 ms 13184 KB Output is correct
2 Correct 326 ms 15856 KB Output is correct
3 Correct 318 ms 15928 KB Output is correct
4 Correct 309 ms 15600 KB Output is correct
5 Correct 258 ms 13432 KB Output is correct
6 Correct 319 ms 15856 KB Output is correct
7 Correct 316 ms 15704 KB Output is correct
8 Correct 381 ms 18504 KB Output is correct
9 Correct 261 ms 13808 KB Output is correct
10 Correct 330 ms 15864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4096 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 328 ms 14920 KB Output is partially correct - 772365 bits used
2 Correct 321 ms 15088 KB Output is partially correct - 742095 bits used
3 Correct 311 ms 15344 KB Output is partially correct - 712470 bits used
4 Correct 330 ms 15344 KB Output is partially correct - 712005 bits used
5 Correct 323 ms 15344 KB Output is partially correct - 710610 bits used
6 Correct 323 ms 15608 KB Output is partially correct - 712155 bits used
7 Correct 321 ms 15344 KB Output is partially correct - 711090 bits used
8 Correct 324 ms 15480 KB Output is partially correct - 713340 bits used
9 Correct 327 ms 15600 KB Output is partially correct - 712830 bits used
10 Correct 407 ms 17904 KB Output is partially correct - 1117620 bits used