Submission #363022

# Submission time Handle Problem Language Result Execution time Memory
363022 2021-02-05T02:53:10 Z 2qbingxuan Last supper (IOI12_supper) C++14
0 / 100
476 ms 20556 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
    const int LG = __lg(N) + 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < LG; j++) {
            WriteAdvice(C[i] >> j & 1);
        }
    }
    // cerr << "C = ";
    // for (int i = 0; i < N; i++)
    //     cerr << C[i] << ' ';
    // cerr << '\n';
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

const int maxn = 100025;

int C[maxn];
vector<int> last[maxn];
int scaffold[maxn];
bool onScaffold[maxn];

void Assist(unsigned char *A, int N, int K, int R) {
    const int LG = __lg(N) + 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < LG; j++) {
            C[i] |= A[i*LG + j] * (1<<j);
        }
    }
    // cerr << "C = ";
    // for (int i = 0; i < N; i++)
    //     cerr << C[i] << ' ';
    // cerr << '\n';
    
    auto getLast = [](int i) {
        return last[i].empty()
            ? maxn
            : last[i].back();
    };

    for (int i = N-1; i >= 0; i--)
        last[C[i]].push_back(i);
    set<pair<int,int>, greater<>> st; // last, j
    for (int i = 0; i < K; i++) {
        scaffold[i] = i;
        onScaffold[i] = true;
        st.insert({ getLast(i), i });
    }


    for (int i = 0; i < N; i++) {
        int req = GetRequest();
        if (!onScaffold[req]) {
            int pos = st.begin() -> second;
            st.erase(st.begin());
            last[req].pop_back();
            st.insert({ getLast(req), pos });
            PutBack(scaffold[pos]);
            onScaffold[scaffold[pos]] = false;
            onScaffold[req] = true;
            scaffold[pos] = req;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3284 KB Output is correct
2 Incorrect 3 ms 3588 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 4556 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 354 ms 16004 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3328 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 456 ms 18948 KB Output isn't correct - not an optimal way
2 Incorrect 458 ms 18828 KB Output isn't correct - not an optimal way
3 Incorrect 476 ms 19460 KB Output isn't correct - not an optimal way
4 Incorrect 450 ms 18956 KB Output isn't correct - not an optimal way
5 Incorrect 453 ms 19416 KB Output isn't correct - not an optimal way
6 Incorrect 455 ms 19212 KB Output isn't correct - not an optimal way
7 Incorrect 446 ms 19212 KB Output isn't correct - not an optimal way
8 Incorrect 453 ms 19384 KB Output isn't correct - not an optimal way
9 Incorrect 458 ms 19104 KB Output isn't correct - not an optimal way
10 Correct 452 ms 20556 KB Output is partially correct - 1700000 bits used