Submission #157308

# Submission time Handle Problem Language Result Execution time Memory
157308 2019-10-10T14:16:20 Z dolphingarlic Last supper (IOI12_supper) C++14
0 / 100
268 ms 141600 KB
#include "advisor.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;

set<pair<int, int>> scaffold;
queue<int> occurrences[100000];
int swap_sequence[100000];
bool on_scaffold[100000];

void ComputeAdvice(int *C, int N, int K, int M) {
    FOR(i, 0, N) occurrences[C[i]].push(i);
    FOR(i, 0, N) occurrences[i].push(INT_MAX);

    FOR(i, 0, K) scaffold.insert({-occurrences[i].front(), i});

    FOR(i, 0, N) {
        if (on_scaffold[C[i]]) {
            swap_sequence[i] = C[i];
            scaffold.erase({-occurrences[C[i]].front(), C[i]});
        } else {
            swap_sequence[i] = (*scaffold.begin()).second;
            on_scaffold[(*scaffold.begin()).second] = false;
            scaffold.erase(scaffold.begin());
        }
        occurrences[C[i]].pop();
        scaffold.insert({-occurrences[C[i]].front(), C[i]});
        on_scaffold[C[i]] = true;
    }

    FOR(i, 0, K) WriteAdvice(0);
    FOR(i, 0, N) {
        WriteAdvice(1);
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;

set<pair<int, int>> scaffold;
int on_scaffold[100000];

void Assist(unsigned char *A, int N, int K, int R) {
    FOR(i, 0, K) {
        scaffold.insert({A[i], i});
        on_scaffold[i] = A[i] + 1;
    }

    FOR(i, K, N + K) {
        int nxt = GetRequest();
        if (on_scaffold[nxt]) {
            scaffold.erase({on_scaffold[nxt] - 1, nxt});
            scaffold.insert({A[i], nxt});
        } else {
            PutBack((*scaffold.begin()).second);
            on_scaffold[(*scaffold.begin()).second] = 0;
            scaffold.erase(scaffold.begin());
            scaffold.insert({A[i], nxt});
        }
        on_scaffold[nxt] = A[i] + 1;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 135152 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 135920 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 221 ms 140112 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 135504 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 267 ms 140912 KB Output isn't correct - not an optimal way
2 Incorrect 259 ms 140952 KB Output isn't correct - not an optimal way
3 Incorrect 265 ms 141296 KB Output isn't correct - not an optimal way
4 Incorrect 266 ms 141496 KB Output isn't correct - not an optimal way
5 Incorrect 264 ms 141600 KB Output isn't correct - not an optimal way
6 Incorrect 264 ms 141560 KB Output isn't correct - not an optimal way
7 Incorrect 265 ms 141480 KB Output isn't correct - not an optimal way
8 Incorrect 268 ms 141296 KB Output isn't correct - not an optimal way
9 Incorrect 265 ms 141416 KB Output isn't correct - not an optimal way
10 Incorrect 247 ms 141296 KB Output isn't correct - not an optimal way