#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
multiset<pair<int,int>> ms;
set<int> st[25001];
int k,lg;
void rt(int num){
for(int i = lg-1 ; i >= 0 ; i -= 1){
if(num & (1<<i)){
WriteAdvice(1);
}else{
WriteAdvice(0);
}
}
}
void ComputeAdvice(int *C , int n , int K , int M){
k = K , lg = ceil(log2(n+1));
for(int i = 0 ; i < n ; i += 1){
st[C[i]].insert(i);
st[i].insert(n);
}
for(int i = 0 ; i < k ; i += 1){
ms.insert({*st[i].upper_bound(-1),i});
}
for(int i = 0 ; i < n ; i += 1){
if(ms.find({i,C[i]}) != ms.end()){
ms.erase({i,C[i]});
ms.insert({*st[C[i]].upper_bound(i),C[i]});
rt(k);
}else{
pair<int,int> bd = *(--ms.end());
ms.erase(bd);
rt(bd.second);
ms.insert({*st[C[i]].upper_bound(i),C[i]});
}
/*cout << -1 << endl;
for(auto j : ms){
cout << j.first << " " << j.second << endl;
}cout << endl << endl;*/
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
int lg2;
void Assist(unsigned char *A , int n , int k , int R) {
lg2 = ceil(log2(n+1));
for(int i = 0 ; i < n ; i += 1){
int num = 0 , num2 = GetRequest();
for(int j = lg2*i ; j < lg2*(i+1) ; j += 1){
num = 2*num;
if(A[j] == '1'){
num += 1;
}
}
// cout << "-1 " << A[1] << " " << num << endl;
if(num == k){
continue;
}
PutBack(num);
}
// int i;
// for (i = 0; i < N; i++) {
// int req = GetRequest();
// if (req >= K)
// PutBack(req % K);
// }
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:9:17: warning: unused variable 'num2' [-Wunused-variable]
9 | int num = 0 , num2 = GetRequest();
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1644 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
3856 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
3916 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2176 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
4168 KB |
Execution killed with signal 11 |
2 |
Runtime error |
15 ms |
4104 KB |
Execution killed with signal 11 |
3 |
Runtime error |
15 ms |
4084 KB |
Execution killed with signal 11 |
4 |
Runtime error |
17 ms |
4164 KB |
Execution killed with signal 11 |
5 |
Runtime error |
15 ms |
4096 KB |
Execution killed with signal 11 |
6 |
Runtime error |
15 ms |
4172 KB |
Execution killed with signal 11 |
7 |
Runtime error |
14 ms |
4172 KB |
Execution killed with signal 11 |
8 |
Runtime error |
15 ms |
4176 KB |
Execution killed with signal 11 |
9 |
Runtime error |
15 ms |
4136 KB |
Execution killed with signal 11 |
10 |
Runtime error |
15 ms |
4132 KB |
Execution killed with signal 11 |