#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;
}
int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
st.erase(st.find({furt, C[i]}));
while(dq[C[i]].size() && dq[C[i]].front() <= i) dq[C[i]].pop_front();
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 |
Runtime error |
133 ms |
137324 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
140 ms |
137708 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
160 ms |
139756 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
140 ms |
137452 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
162 ms |
140012 KB |
Execution killed with signal 6 |
2 |
Runtime error |
159 ms |
140396 KB |
Execution killed with signal 11 |
3 |
Runtime error |
168 ms |
140524 KB |
Execution killed with signal 6 |
4 |
Runtime error |
167 ms |
140652 KB |
Execution killed with signal 6 |
5 |
Runtime error |
162 ms |
140524 KB |
Execution killed with signal 6 |
6 |
Runtime error |
177 ms |
140524 KB |
Execution killed with signal 6 |
7 |
Runtime error |
161 ms |
140468 KB |
Execution killed with signal 6 |
8 |
Runtime error |
160 ms |
140524 KB |
Execution killed with signal 11 |
9 |
Runtime error |
161 ms |
140524 KB |
Execution killed with signal 6 |
10 |
Runtime error |
163 ms |
140652 KB |
Execution killed with signal 11 |