Submission #153117

# Submission time Handle Problem Language Result Execution time Memory
153117 2019-09-12T13:23:40 Z popovicirobert Last supper (IOI12_supper) C++14
0 / 100
199 ms 7708 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;
            if(pq.lower_bound({i, -1}) == pq.end()) {
                while(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});
        pos[C[i]] = i + k;
        /*for(auto it : pq) {
            cerr << it.first << " " << it.second << "\n";
        }
        cerr << "\n";*/
    }

    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] << " ";
    }*/

    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 Correct 4 ms 760 KB Output is correct
2 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 892 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 Runtime error 50 ms 2916 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 Runtime error 4 ms 632 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 Runtime error 61 ms 3504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 62 ms 3508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 65 ms 3460 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 190 ms 7624 KB Output isn't correct - not an optimal way
5 Incorrect 188 ms 7540 KB Output isn't correct - not an optimal way
6 Runtime error 65 ms 3456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Incorrect 199 ms 7708 KB Output isn't correct - not an optimal way
8 Runtime error 68 ms 3372 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Incorrect 191 ms 7448 KB Output isn't correct - not an optimal way
10 Runtime error 53 ms 3456 KB Execution killed with signal 11 (could be triggered by violating memory limits)