Submission #624946

# Submission time Handle Problem Language Result Execution time Memory
624946 2022-08-09T07:54:33 Z pirhosig Last supper (IOI12_supper) C++17
0 / 100
147 ms 16676 KB
#include "advisor.h"
#include <bits/stdc++.h>
#define  R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;



void ComputeAdvice(int *C, int N, int K, int M) {
    unordered_map<int, vector<int>> mpa;
    R(N) {
        int a = C[i];
        mpa[a].push_back(i);
    }

    unordered_set<int> val;
    R(K) {
        val.insert(i);
    }

    vector<int> nxt(N, INT_MAX);
    priority_queue<ii> que;
    R(K) {
        if (!mpa[i].size()) que.push({INT_MAX, i});
        else {
            que.push({mpa[i][0], i});
            nxt[i] = mpa[i][0];
        }
    }

    bool init[K] {};
    bool rem[N] {};
    vector<int> last(N, -1);
    R(N) {
        int a = C[i];
        last[a] = i;
        if (!val.count(a)) {
            while (nxt[que.top().second] != que.top().first) {
                que.pop();
            }
            auto b = que.top();
            que.pop();
            int c = b.second;
            if (last[c] == -1) init[c] = true;
            else rem[last[c]] = true;
        }

        auto it = upper_bound(mpa[a].begin(), mpa[a].end(), i);
        if (it == mpa[a].end()) {
            que.push({INT_MAX, a});
            nxt[a] = INT_MAX;
        }
        else {
            que.push({*it, a});
            nxt[a] = *it;
        }
    }

    R(K) {
        if (init[i]) WriteAdvice(1);
        else WriteAdvice(0);
    }
    R(N) {
        if (rem[i]) WriteAdvice(1);
        else WriteAdvice(0);
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
#define  R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;



void Assist(unsigned char *A, int N, int K, int R) {
    queue<int> rem;
    unordered_set<int> val;

    R(K) {
        val.insert(i);
        if (A[i]) rem.push(i);
    }
    R(N) {
        int a = GetRequest();
        if (!val.count(a)) {
            PutBack(rem.front());
            rem.pop();
        }
        if (A[K + i]) {
            rem.push(a);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 548 KB Output is correct
2 Incorrect 1 ms 512 KB Error - Putting back a color when it is already on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1784 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 10876 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1200 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 147 ms 12784 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 119 ms 13428 KB Error - Putting back a color when it is already on the scaffold
3 Incorrect 118 ms 13644 KB Error - Putting back a color when it is already on the scaffold
4 Incorrect 144 ms 13452 KB Error - Putting back a color when it is already on the scaffold
5 Incorrect 135 ms 13528 KB Error - Putting back a color when it is already on the scaffold
6 Incorrect 138 ms 13532 KB Error - Putting back a color when it is already on the scaffold
7 Incorrect 137 ms 13432 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 102 ms 13444 KB Error - Putting back a color when it is already on the scaffold
9 Incorrect 117 ms 13636 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 111 ms 16676 KB Error - Putting back a color when it is already on the scaffold