Submission #362871

# Submission time Handle Problem Language Result Execution time Memory
362871 2021-02-04T14:21:36 Z 79brue Last supper (IOI12_supper) C++14
0 / 100
213 ms 14008 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;

typedef long long ll;

struct dat{
    int l, r, x;
    dat(){}
    dat(int l, int r, int x): l(l), r(r), x(x){}

    bool operator<(const dat &nxt)const{
        return r<nxt.r;
    }
};

int n, k, m;
int arr[100002];
vector<int> occurence[100002];
set<dat> st;
set<int> now;
vector<bool> bits;

void ComputeAdvice(int *C, int N, int K, int M){
    n = N, k = K, m = M;
    bits.resize(n+k);
    for(int i=0; i<n; i++){
        arr[i] = C[i];
        occurence[arr[i]].push_back(i);
    }
    for(int i=0; i<n; i++){
        occurence[i].push_back(1e9);
        reverse(occurence[i].begin(), occurence[i].end());
    }

    for(int i=0; i<k; i++){
        now.insert(i);
        st.insert(dat(i, occurence[i].back(), i));
    }

    for(int i=0; i<n; i++){
        occurence[arr[i]].pop_back();
        if(now.find(arr[i]) != now.end()) continue;
        dat tmp = *st.rbegin();
        st.erase(prev(st.end()));
        now.erase(tmp.x);
        bits[tmp.l] = true;

        st.insert(dat(k+i, occurence[arr[i]].back(), arr[i]));
        now.insert(arr[i]);
    }

    for(int i=0; i<n+k; i++){
        WriteAdvice(bits[i]);
    }
    return;
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

typedef long long ll;

namespace {
    int n, k, r;
    bool arr[200002];
    vector<int> order;
    set<int> st;
    stack<int> stk;
}

void Assist(unsigned char *A, int N, int K, int R){
    n = N, k = K, r = R;
    assert(r = n+k);
    for(int i=0; i<r; i++) arr[i] = A[i];
    for(int i=0; i<k; i++){
        order.push_back(i);
        st.insert(i);
        if(arr[i]) stk.push(i);
    }

    for(int i=k; i<n+k; i++){
        int tmp = GetRequest();
        order.push_back(tmp);
        if(st.find(tmp) == st.end()){
            int tmp2 = stk.top();
            PutBack(tmp2);
            stk.pop();

            st.erase(tmp2);
            st.insert(tmp);
        }
        if(arr[i]) stk.push(tmp);
    }
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3232 KB Output is correct
2 Incorrect 2 ms 3172 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 4132 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 11892 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 3588 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 13128 KB Output isn't correct - not an optimal way
2 Incorrect 208 ms 13132 KB Output isn't correct - not an optimal way
3 Incorrect 197 ms 13632 KB Output isn't correct - not an optimal way
4 Incorrect 195 ms 13876 KB Output isn't correct - not an optimal way
5 Incorrect 205 ms 13504 KB Output isn't correct - not an optimal way
6 Incorrect 191 ms 13368 KB Output isn't correct - not an optimal way
7 Incorrect 194 ms 13688 KB Output isn't correct - not an optimal way
8 Incorrect 213 ms 13504 KB Output isn't correct - not an optimal way
9 Incorrect 191 ms 13792 KB Output isn't correct - not an optimal way
10 Incorrect 183 ms 14008 KB Output isn't correct - not an optimal way