Submission #1037963

# Submission time Handle Problem Language Result Execution time Memory
1037963 2024-07-29T11:22:01 Z idas Last supper (IOI12_supper) C++11
0 / 100
54 ms 10108 KB
#include <bits/stdc++.h>
#include "advisor.h"

#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define s second
#define f first

using namespace std;
typedef pair<int, int> pii;

const int MxN=1e5+10;
int n, k, c[MxN], nxt[MxN], cur[MxN], bits[2*MxN], id[MxN];

void ComputeAdvice(int *C, int N, int K, int M) {
    n=N; k=K; FOR(i, 0, n) c[i]=C[i], cur[i]=-1;
    for(int i=n-1; i>=0; i--){
        nxt[i+k]=cur[c[i]];
        cur[c[i]]=i;
    }
    FOR(i, 0, k) nxt[i]=cur[i], id[i]=i;

    set<pii, greater<pii>> st;
    FOR(i, 0, k) st.insert({nxt[i],i});

    FOR(i, 0, n)
    {
        auto it=st.begin();
        int in=(*it).s;
        st.erase(it);

        int col;
        if(in<k) col=in;
        else col=c[in-k];

        if(c[i]!=col) bits[in]=1;

        st.insert({nxt[i+k], i+k});
    }

    FOR(i, 0, n+k) WriteAdvice(bits[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"

#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define pb push_back
#define s second
#define f first

using namespace std;
typedef vector<int> vi;

const int MxN=1e5+10;
int n, k, r, bits[MxN];

void Assist(unsigned char *A, int N, int K, int R) {
    n=N; k=K; r=R; FOR(i, 0, r) bits[i]=(A[i]=='1'?1:0);

    vi bad;
    set<int> cols;
    FOR(i, 0, k)
    {
        cols.insert(i);
        if(bits[i]) bad.pb(i);
    }

    FOR(i, k, n+k)
    {
        int next_col=GetRequest();
        if(!cols.count(next_col)){
            cols.erase(bad.back());
            PutBack(bad.back());
            bad.pop_back();

            cols.insert(next_col);
            if(bits[i]) bad.pb(next_col);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 2832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 3676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 10108 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 3136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 53 ms 9304 KB Execution killed with signal 11
2 Runtime error 50 ms 9476 KB Execution killed with signal 11
3 Runtime error 42 ms 9532 KB Execution killed with signal 11
4 Runtime error 42 ms 9692 KB Execution killed with signal 11
5 Runtime error 42 ms 9740 KB Execution killed with signal 11
6 Runtime error 42 ms 9656 KB Execution killed with signal 11
7 Runtime error 54 ms 9448 KB Execution killed with signal 11
8 Runtime error 42 ms 9596 KB Execution killed with signal 11
9 Runtime error 42 ms 9584 KB Execution killed with signal 11
10 Runtime error 41 ms 9616 KB Execution killed with signal 11