Submission #153115

# Submission time Handle Problem Language Result Execution time Memory
153115 2019-09-12T13:12:37 Z popovicirobert Last supper (IOI12_supper) C++14
0 / 100
66 ms 7664 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;


void ComputeAdvice(int *C, int n, int k, int M) {

    vector <int> last(n, n), nxt(n);
    int i;

    for(i = n - 1; i >= 0; i--) {
        nxt[i] = last[C[i]];
        last[C[i]] = i;
    }

    set < pair <int, int> > pq;
    vector <int> pos(n, -1);

    for(i = 0; i < k; i++) {
        pq.insert({last[i], i});
        pos[i] = i;
    }

    vector <unsigned char> sol(n + k, '0');
    for(i = 0; i < n; i++) {
        if(pos[C[i]] != -1) {
            sol[pos[C[i]]] = '1';
            pq.erase(pq.lower_bound({i, -1}));
        }
        else {
            pos[prev(pq.end()) -> second] = -1;
            pq.erase(prev(pq.end()));
        }
        pq.insert({nxt[i], i + k});
        /*for(auto it : pq) {
            cerr << it.first << " " << it.second << "\n";
        }
        cerr << "\n";*/
        pos[C[i]] = i + k;
    }

    for(auto it : sol) {
        WriteAdvice(it);
    }
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

void Assist(unsigned char *A, int n, int k, int R) {
    set <int> col, bad;
    int i;

    /*cerr << n + k << "\n";
    for(i = 0; i < n + k; i++) {
        cerr << (int) A[i] - '0' << " ";
    }*/

    for(i = 0; i < k; i++) {
        col.insert(i);
        if(A[i] == '0') {
            bad.insert(i);
        }
    }

    for(i = k; i < n + k; i++) {
        int cur = GetRequest();
        if(col.count(cur) == 0) {
            PutBack(*bad.begin());
            col.erase(*bad.begin());
            bad.erase(bad.begin());
        }
        if(A[i] == '0') {
            bad.insert(cur);
        }
        col.insert(cur);
    }

}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 996 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 6128 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 7152 KB Error - advice must be 0 or 1
2 Incorrect 59 ms 7360 KB Error - advice must be 0 or 1
3 Incorrect 61 ms 7608 KB Error - advice must be 0 or 1
4 Incorrect 59 ms 7664 KB Error - advice must be 0 or 1
5 Incorrect 63 ms 7408 KB Error - advice must be 0 or 1
6 Incorrect 66 ms 7664 KB Error - advice must be 0 or 1
7 Incorrect 59 ms 7560 KB Error - advice must be 0 or 1
8 Incorrect 58 ms 7632 KB Error - advice must be 0 or 1
9 Incorrect 57 ms 7408 KB Error - advice must be 0 or 1
10 Incorrect 45 ms 7408 KB Error - advice must be 0 or 1