# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829942 | Blagoj | Last supper (IOI12_supper) | C++17 | 2559 ms | 20868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
queue<int> toDelete;
unordered_map<int, int> cnt;
set<int> s[N + 2];
int Last[N + 2];
for (int i = 0; i < N; i++) {
cnt[C[i]]++;
s[C[i]].insert(i + K);
}
for (int i = 0; i < K; i++) {
Last[i] = i;
if (!cnt[i]) toDelete.push(i);
}
vector<int> op(N + K);
unordered_set<int> have;
for (int i = 0; i < K; i++) {
have.insert(i);
if (!cnt[i]) op[i] = 1;
}
for (int i = 0; i < N; i++) {
Last[C[i]] = i + K;
if (have.count(C[i])) {
cnt[C[i]]--;
if (!cnt[C[i]]) {
toDelete.push(C[i]);
op[i + K] = 1;
}
}
else {
if (toDelete.size() == 0) {
int last, position = -1;
for (int x : have) {
int temp = *s[x].lower_bound(i);
if (temp > position) {
position = temp;
last = x;
}
}
toDelete.push(last);
op[Last[last]] = 1;
}
int fr = toDelete.front();
toDelete.pop();
have.erase(fr);
have.insert(C[i]);
cnt[C[i]]--;
if (!cnt[C[i]]) {
toDelete.push(C[i]);
op[i + K] = 1;
}
}
}
for (int i = 0; i < op.size(); i++) {
WriteAdvice(op[i]);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
queue<int> toDelete;
unordered_set<int> have;
for (int i = 0; i < K; i++) {
if (A[i] == 1) toDelete.push(i);
have.insert(i);
}
for (int i = 0; i < N; i++) {
int req = GetRequest();
if (!have.count(req)) {
PutBack(toDelete.front());
have.erase(toDelete.front());
toDelete.pop();
have.insert(req);
}
if (A[i + K] == 1) {
toDelete.push(req);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |