Submission #363048

# Submission time Handle Problem Language Result Execution time Memory
363048 2021-02-05T03:35:19 Z 2qbingxuan Last supper (IOI12_supper) C++14
8 / 100
360 ms 19796 KB
#include "advisor.h"
#include <iostream>
using std::cerr;
 
const int LG = 13;
void ComputeAdvice(int *C, int N, int K, int M) {
    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 <iostream>
#include <vector>
#include <cassert>
#include <set>
#include <utility>
using std::cerr;
using std::vector;
using std::set;
using std::pair;
 
const int maxn = 100025;
const int LG = 13;
 
int C[maxn];
vector<int> last[maxn];
int scaffold[maxn];
int onScaffold[maxn];
 
void Assist(unsigned char *A, int N, int K, int R) {
    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';
    for (int i = 0; i < K; i++)
        scaffold[i] = i, onScaffold[i] = i;
    for (int i = K; i < N; i++)
        onScaffold[i] = -1;
    for (int i = 0; i < N; i++)
        last[i].push_back(maxn);
    for (int i = N-1; i >= 0; i--)
        last[C[i]].push_back(i);

    set<pair<int,int>> st;
    for (int i = 0; i < K; i++)
        st.insert({ -last[i].back(), i });

    for (int i = 0; i < N; i++) {
        int req = GetRequest();

        if (onScaffold[req] == -1) {
            last[C[i]].pop_back();
            int pos = st.begin() -> second;
            st.erase(st.begin());
            onScaffold[req] = pos;
            onScaffold[scaffold[pos]] = -1;
            PutBack(scaffold[pos]);
            scaffold[pos] = req;
            st.insert({ -last[C[i]].back(), pos });
        } else {
            int pos = onScaffold[C[i]];
            st.erase({ -last[C[i]].back(), pos });
            last[C[i]].pop_back();
            st.insert({ -last[C[i]].back(), pos });
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3044 KB Output is correct
2 Correct 3 ms 3172 KB Output is correct
3 Correct 7 ms 3332 KB Output is correct
4 Correct 13 ms 3648 KB Output is correct
5 Correct 19 ms 3724 KB Output is correct
6 Correct 23 ms 3708 KB Output is correct
7 Correct 19 ms 3836 KB Output is correct
8 Correct 19 ms 3844 KB Output is correct
9 Correct 19 ms 3708 KB Output is correct
10 Correct 19 ms 3852 KB Output is correct
11 Correct 19 ms 3708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 4520 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 278 ms 16052 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3284 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 346 ms 18764 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 346 ms 19224 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 360 ms 19516 KB Output isn't correct - not an optimal way
4 Incorrect 357 ms 19796 KB Output isn't correct - not an optimal way
5 Incorrect 344 ms 19224 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 340 ms 18924 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 357 ms 19672 KB Output isn't correct - not an optimal way
8 Incorrect 356 ms 19692 KB Output isn't correct - not an optimal way
9 Incorrect 352 ms 19524 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 356 ms 19164 KB Output isn't correct - not an optimal way