Submission #102013

#TimeUsernameProblemLanguageResultExecution timeMemory
102013naoaiLast supper (IOI12_supper)C++14
0 / 100
498 ms16880 KiB

#include "advisor.h"

#include <bits/stdc++.h>

using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
    int n2 = 0;
    for (n2 = 0; (1 << (n2 + 1)) < N; ++ n2) {
    }

    for (int i = 0; i < N; ++ i) {
        int x = C[i];
        for (int j = 0; j <= n2; ++ j) {
            WriteAdvice(x % 2);
            x /= 2;
        }
    }
}

#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;

const int nmax = 1e5;
bool viz[nmax + 1];

int f[nmax + 1];
int nxt[nmax + 1];

void Assist(unsigned char *A, int N, int K, int R) {
    vector<int> c;
    int n2 = 0;
    for (n2 = 0; (1 << (n2 + 1)) < N; ++ n2) {
    }

    for (int i = 0; i < R; i += n2 + 1) {
        int x = 0;
        int p2 = 1;
        for (int j = i; j <= i + n2; ++ j) {
            x = x + p2 * A[j];
            p2 *= 2;
        }
        c.push_back(x);
    }

    for (int i = 0; i < N; ++ i)
        f[i] = (1 << 30);

    for (int i = N - 1; i > 0; -- i) {
        nxt[i] = -f[c[i]];
        f[c[i]] = i;
    }

    set<pair<int, int>> s;
    for (int i = 0; i < K; ++ i) {
        viz[i] = 1;
        s.insert({-f[i], i});
    }


    int i;
    for (i = 0; i < N; i++) {
        int req = GetRequest();
        if (viz[req] == 1) {
            s.erase({-i, req});
        } else {
            int x = s.begin() -> second;
            PutBack(x);
            viz[x] = 0;

            s.erase(s.begin());
        }

        viz[req] = 1;
        s.insert({nxt[i], req});
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...