Submission #170071

# Submission time Handle Problem Language Result Execution time Memory
170071 2019-12-24T01:19:48 Z tri Last supper (IOI12_supper) C++14
0 / 100
198 ms 140664 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;

#define pb push_back
#define f first
#define s second

const int MAXN = 1e5;

queue<int> nUse[MAXN];

void ComputeAdvice(int *C, int N, int K, int M) {
    vi used(2 * N, 0);
    vi tInsert(N, 0);
    vi contain(N, 0);

    for (int i = 0; i < N; i++) {
        nUse[C[i]].push(i);
    }

    for (int cC = 0; cC < N; cC++) {
        nUse[cC].push(N);
    }

    priority_queue<pi> allNext;

    for (int cC = 0; cC < K; cC++) {
        allNext.push({nUse[cC].front(), cC});
        contain[cC] = true;
        tInsert[cC] = cC;
    }

    int cntRem = 0;
    for (int i = 0; i < N; i++) {
        int cC = C[i];
        nUse[cC].pop();
        if (contain[cC]) {
            used[tInsert[cC]] = true;
            tInsert[cC] = i + K;
        } else {
            cntRem++;
            pi furtUse = allNext.top();
            allNext.pop();
            contain[furtUse.s] = false;

            allNext.push({nUse[cC].front(), cC});
            contain[cC] = true;
            tInsert[cC] = i + K;
        }
    }

//    cout << "cntRem: " << cntRem << endl;

    for (int i = 0; i < 2 * N; i++) {
        WriteAdvice(used[i]);
    }
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;

#define pb push_back
#define f first
#define s second

namespace debug {
    const int DEBUG = true;

    template<class T1, class T2>
    void pr(const pair<T1, T2> &x);

    template<class T, size_t SZ>
    void pr(const array<T, SZ> &x);

    template<class T>
    void pr(const vector<T> &x);

    template<class T>
    void pr(const set<T> &x);

    template<class T1, class T2>
    void pr(const map<T1, T2> &x);

    template<class T>
    void pr(const T &x) { if (DEBUG) cout << x; }

    template<class T, class... Ts>
    void pr(const T &first, const Ts &... rest) { pr(first), pr(rest...); }

    template<class T1, class T2>
    void pr(const pair<T1, T2> &x) { pr("{", x.f, ", ", x.s, "}"); }

    template<class T>
    void prIn(const T &x) {
        pr("{");
        bool fst = 1;
        for (auto &a : x) {
            pr(fst ? "" : ", ", a), fst = 0;
        }
        pr("}");
    }

    template<class T, size_t SZ>
    void pr(const array<T, SZ> &x) { prIn(x); }

    template<class T>
    void pr(const vector<T> &x) { prIn(x); }

    template<class T>
    void pr(const set<T> &x) { prIn(x); }

    template<class T1, class T2>
    void pr(const map<T1, T2> &x) { prIn(x); }

    void ps() { pr("\n"), cout << flush; }

    template<class Arg, class... Args>
    void ps(const Arg &first, const Args &... rest) {
        pr(first, " ");
        ps(rest...);
    }
}
using namespace debug;

const int MAXN = 1e5;

void Assist(unsigned char *data, int N, int K, int R) {
    queue<int> unused;
    vi contain(N, 0);

//    cout << "data   ";
//    for (int i = 0; i < 2 * N; i++) {
//        cout << (data[i] == 1) << ", ";
//    }
//    cout << endl;

    for (int i = 0; i < K; i++) {
        if (data[i] == 0) {
            unused.push(i);
//            ps("push", i);
        }
        contain[i] = true;
    }

    for (int i = 0; i < N; i++) {
        int cC = GetRequest();
        if (contain[cC]) {
            if (data[i + K] == 0) {
                unused.push(cC);
//                ps("push:", cC);
            }
        } else {
            assert(unused.size() > 0);

            int remC = unused.front();
            unused.pop();

            contain[remC] = false;
            PutBack(remC);

            contain[cC] = true;
            if (data[i + K] == 0) {
                unused.push(cC);
//                ps("push:", cC);
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 72 ms 135408 KB Output is correct
2 Incorrect 72 ms 135408 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 136056 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 160 ms 139504 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 75 ms 135664 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 140528 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 190 ms 140520 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 191 ms 140488 KB Output isn't correct - not an optimal way
4 Incorrect 191 ms 140664 KB Output isn't correct - not an optimal way
5 Incorrect 192 ms 140528 KB Output isn't correct - not an optimal way
6 Incorrect 192 ms 140528 KB Output isn't correct - not an optimal way
7 Incorrect 191 ms 140536 KB Output isn't correct - not an optimal way
8 Incorrect 190 ms 140528 KB Output isn't correct - not an optimal way
9 Incorrect 188 ms 140528 KB Output isn't correct - not an optimal way
10 Correct 198 ms 140528 KB Output is correct - 200000 bits used