# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
412763 |
2021-05-27T13:13:36 Z |
KoD |
Last supper (IOI12_supper) |
C++17 |
|
564 ms |
21228 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]);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
template <class T>
using Vec = std::vector<T>;
int read(unsigned char *A, const int width) {
static int idx = 0;
int bit = 0;
for (int i = 0; i < width; ++i) {
if (A[idx++]) {
bit += 1 << i;
}
}
return bit;
}
void Assist(unsigned char *A, int N, int K, int R) {
std::map<int, int> map;
Vec<int> cur(K);
for (int i = 0; i < K; ++i) {
cur[i] = i;
}
int width = 0;
while ((1 << width) <= K) width += 1;
for (int i = 0; i < N; ++i) {
const auto c = GetRequest();
const auto k = read(A, width);
if (k != K) {
const auto j = cur[k];
PutBack(j);
cur[k] = c;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
484 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
5 ms |
760 KB |
Output is correct |
4 |
Correct |
7 ms |
776 KB |
Output is correct |
5 |
Correct |
8 ms |
1072 KB |
Output is correct |
6 |
Correct |
13 ms |
1340 KB |
Output is correct |
7 |
Correct |
15 ms |
1248 KB |
Output is correct |
8 |
Correct |
18 ms |
1460 KB |
Output is correct |
9 |
Correct |
17 ms |
1372 KB |
Output is correct |
10 |
Correct |
19 ms |
1512 KB |
Output is correct |
11 |
Correct |
19 ms |
1480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
2036 KB |
Output is correct |
2 |
Correct |
211 ms |
7912 KB |
Output is correct |
3 |
Correct |
530 ms |
21228 KB |
Output is correct |
4 |
Correct |
279 ms |
14100 KB |
Output is correct |
5 |
Correct |
358 ms |
15968 KB |
Output is correct |
6 |
Correct |
495 ms |
18092 KB |
Output is correct |
7 |
Correct |
515 ms |
20116 KB |
Output is correct |
8 |
Correct |
429 ms |
18736 KB |
Output is correct |
9 |
Correct |
175 ms |
10920 KB |
Output is correct |
10 |
Correct |
508 ms |
20864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
438 ms |
15528 KB |
Output is correct |
2 |
Correct |
516 ms |
19472 KB |
Output is correct |
3 |
Correct |
546 ms |
19400 KB |
Output is correct |
4 |
Correct |
562 ms |
19184 KB |
Output is correct |
5 |
Correct |
482 ms |
18424 KB |
Output is correct |
6 |
Correct |
564 ms |
19468 KB |
Output is correct |
7 |
Correct |
484 ms |
19400 KB |
Output is correct |
8 |
Correct |
509 ms |
20576 KB |
Output is correct |
9 |
Correct |
462 ms |
18724 KB |
Output is correct |
10 |
Correct |
522 ms |
19496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
876 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
505 ms |
19040 KB |
Output is partially correct - 1500000 bits used |
2 |
Correct |
502 ms |
19196 KB |
Output is partially correct - 1500000 bits used |
3 |
Correct |
538 ms |
19372 KB |
Output is partially correct - 1500000 bits used |
4 |
Correct |
558 ms |
19468 KB |
Output is partially correct - 1500000 bits used |
5 |
Correct |
506 ms |
19328 KB |
Output is partially correct - 1500000 bits used |
6 |
Correct |
552 ms |
19320 KB |
Output is partially correct - 1500000 bits used |
7 |
Correct |
509 ms |
19396 KB |
Output is partially correct - 1497585 bits used |
8 |
Correct |
502 ms |
19468 KB |
Output is partially correct - 1500000 bits used |
9 |
Correct |
521 ms |
19416 KB |
Output is partially correct - 1500000 bits used |
10 |
Correct |
532 ms |
20532 KB |
Output is partially correct - 1500000 bits used |