#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(n);
}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));
// printf("%d\n",a[0]);
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 " << num << endl;
if(num == n){
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:10:17: warning: unused variable 'num2' [-Wunused-variable]
10 | int num = 0 , num2 = GetRequest();
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1640 KB |
Output is correct |
2 |
Correct |
2 ms |
1772 KB |
Output is correct |
3 |
Correct |
5 ms |
1992 KB |
Output is correct |
4 |
Correct |
11 ms |
2360 KB |
Output is correct |
5 |
Correct |
19 ms |
2688 KB |
Output is correct |
6 |
Correct |
19 ms |
2704 KB |
Output is correct |
7 |
Correct |
20 ms |
2788 KB |
Output is correct |
8 |
Correct |
24 ms |
2820 KB |
Output is correct |
9 |
Correct |
22 ms |
2704 KB |
Output is correct |
10 |
Correct |
20 ms |
2968 KB |
Output is correct |
11 |
Correct |
20 ms |
2716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
3712 KB |
Output is correct |
2 |
Runtime error |
9 ms |
3500 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
3404 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2160 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
14 ms |
3532 KB |
Execution killed with signal 11 |
2 |
Runtime error |
15 ms |
3516 KB |
Execution killed with signal 11 |
3 |
Runtime error |
15 ms |
3532 KB |
Execution killed with signal 11 |
4 |
Runtime error |
16 ms |
3588 KB |
Execution killed with signal 11 |
5 |
Runtime error |
15 ms |
3548 KB |
Execution killed with signal 11 |
6 |
Runtime error |
15 ms |
3596 KB |
Execution killed with signal 11 |
7 |
Runtime error |
14 ms |
3532 KB |
Execution killed with signal 11 |
8 |
Runtime error |
15 ms |
3524 KB |
Execution killed with signal 11 |
9 |
Runtime error |
15 ms |
3532 KB |
Execution killed with signal 11 |
10 |
Runtime error |
15 ms |
3532 KB |
Execution killed with signal 11 |