# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
412762 |
2021-05-27T13:13:18 Z |
KoD |
Last supper (IOI12_supper) |
C++17 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "advisor.h"
template <class T>
using Vec = std::vector<T>;
void write(const int width, const int bit) {
for (int i = 0; i < width; ++i) {
WriteAdvice(bit >> i & 1);
}
}
void ComputeAdvice(int *C, int N, int K, int M) {
Vec<Vec<int>> idx(N);
for (int i = 0; i < N; ++i) {
idx[i].push_back(N);
}
for (int i = N - 1; i >= 0; --i) {
idx[C[i]].push_back(i);
}
std::map<int, int> map;
std::set<std::pair<int, int>> que;
for (int i = 0; i < K; ++i) {
map[i] = i;
que.emplace(idx[i].back(), i);
}
int width = 0;
while ((1 << width) <= K) width += 1;
for (int i = 0; i < N; ++i) {
if (que.find(std::make_pair(idx[C[i]].back(), C[i])) == que.end()) {
const auto [t, j] = *que.rbegin();
que.erase(std::make_pair(t, j));
write(width, map[j]);
map[C[i]] = map[j];
}
else {
write(width, K);
que.erase(std::make_pair(idx[C[i]].back(), C[i]));
}
idx[C[i]].pop_back();
que.emplace(idx[C[i]].back(), C[i]);
}
}
Compilation message
/usr/bin/ld: /tmp/ccPpEHHI.o: in function `main':
assistant_grader.cpp:(.text.startup+0x21e): undefined reference to `Assist(unsigned char*, int, int, int)'
collect2: error: ld returned 1 exit status