#include "advisor.h"
#include <iostream>
#include <utility>
#include <cassert>
#include <set>
#include <deque>
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
const int maxN = 1e5 + 326;
bool has[maxN];
set<pii> st;
deque<int> dq[maxN];
void ComputeAdvice(int *C, int N, int K, int M) {
fill(has, has + K, 1);
for(int i = 0; i < N; i++){
dq[C[i]].push_back(i);
}
for(int i = 0; i < K; i++){
int furt = dq[i].size() ? dq[i].front() : maxN;
st.insert({furt, i});
}
int bitcount = 0;
while((1 << bitcount) < N + 1) bitcount++;
for(int i = 0; i < N; i++){ //thirteen bits lol
int key;
if(has[C[i]]) key = (1 << bitcount) - 1;
else {
pii nc = *st.rbegin();
st.erase(st.find(nc));
has[nc.S] = false;
has[C[i]] = true;
key = nc.S;
while(dq[C[i]].size() && dq[C[i]].front() <= i) dq[C[i]].pop_front();
int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
st.insert({furt, C[i]});
}
for(int j = 0; j < bitcount; j++){
WriteAdvice((key >> j) & 1);
}
}
}
#include "assistant.h"
void Assist(unsigned char *A, int N, int K, int R) {
int bitcount = 0;
while((1 << bitcount) < N + 1) bitcount++;
for(int i = 0; i < N; i++){
int req = GetRequest();
int key = 0;
for(int j = (i + 1) * bitcount - 1; j >= (i) * bitcount; j--){
key = key * 2 + A[j];
}
if(key != (1 << bitcount) - 1) PutBack(key);
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:8:7: warning: unused variable 'req' [-Wunused-variable]
8 | int req = GetRequest();
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
68352 KB |
Output is correct |
2 |
Incorrect |
54 ms |
68196 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
91 ms |
69312 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
420 ms |
79164 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
55 ms |
68452 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
505 ms |
81548 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
521 ms |
81788 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
503 ms |
81920 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
506 ms |
81920 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
520 ms |
81904 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
508 ms |
82064 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
508 ms |
81924 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
512 ms |
82060 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
503 ms |
82048 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
523 ms |
81804 KB |
Output is partially correct - 1700000 bits used |