Submission #624950

# Submission time Handle Problem Language Result Execution time Memory
624950 2022-08-09T08:00:05 Z pirhosig Last supper (IOI12_supper) C++17
0 / 100
634 ms 19672 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) {
        cerr << "A " << (int)(A[i]) << endl;
    }
    cerr << "N\n";
    R(N) {
        cerr << "A " << (int)(A[K + i]) << endl;
    }

    R(K) {
        val.insert(i);
        if (A[i]) rem.push(i);
    }
    R(N) {
        int a = GetRequest();
        if (!val.count(a)) {
            val.insert(a);
            PutBack(rem.front());
            rem.pop();
        }
        if (A[K + i]) {
            rem.push(a);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Incorrect 1 ms 516 KB Error - Not putting back color when it is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 2000 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 462 ms 13040 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1232 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 598 ms 13876 KB Error - Not putting back color when it is not on the scaffold
2 Incorrect 634 ms 14264 KB Error - Not putting back color when it is not on the scaffold
3 Incorrect 592 ms 14652 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 564 ms 14660 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 531 ms 14512 KB Error - Not putting back color when it is not on the scaffold
6 Incorrect 534 ms 14740 KB Error - Not putting back color when it is not on the scaffold
7 Incorrect 539 ms 14572 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 536 ms 14588 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 570 ms 14600 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 549 ms 19672 KB Error - Not putting back color when it is not on the scaffold