#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
if(K>25000){
int x = *max_element(C,C+N);
for(int i = 0; i < N; i++)
for(int j = 0; j < (x<5000?13:20); j++)
WriteAdvice((C[i]>>j)&1);
return;
}
set<int> S; set<pair<int,int>> SS; vector<int> v[N+1];
for(int i = 0; i < N; i++) v[C[i]].push_back(i);
for(int i = 0; i < N; i++) v[i].push_back(N+1);
for(int i = 0; i < K; i++){
int nx = *upper_bound(begin(v[i]),end(v[i]),-1);
S.insert(i); SS.insert({nx,i});
}
for(int i = 0; i < N; i++) {
int req = C[i];
if(S.count(req)){
for(int j = 0; j < 15; j++) WriteAdvice(1);
int nx = *upper_bound(begin(v[req]),end(v[req]),i);
SS.erase({i,req}); SS.insert({nx,req});
continue;
}
int getCol = (--end(SS))->second;
S.erase(getCol); S.insert(req);
for(int j = 0; j < 15; j++) WriteAdvice((getCol>>j)&1);
int nx = *upper_bound(begin(v[req]),end(v[req]),i);
SS.erase(--end(SS)); SS.insert({nx,req});
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
if(R==K*15 and K<=25000){
for(int i = 0; i < R; i+=15){
int xd = 0;
for(int j = 0; j < 15; j++)
if(A[i+j]) xd |= (1<<j);
if(xd!=(1<<16)-1) PutBack(xd);
}
return;
}
int C[N+1]; vector<int> v[N+1];
for(int i = 0; i < N; i++) C[i]=0;
const int bit = R%20?13:20;
for(int i = 0; i < R; i++)
if(A[i]) C[i/bit] |= (1<<(i%bit));
set<int> S; set<pair<int,int>> SS;
for(int i = 0; i < N; i++) v[C[i]].push_back(i);
for(int i = 0; i < N; i++) v[i].push_back(N+1);
for(int i = 0; i < K; i++){
int nx = *upper_bound(begin(v[i]),end(v[i]),-1);
S.insert(i); SS.insert({nx,i});
}
for(int i = 0; i < N; i++) {
int req = GetRequest();
if(S.count(req)){
int nx = *upper_bound(begin(v[req]),end(v[req]),i);
SS.erase({i,req}); SS.insert({nx,req});
continue;
}
int getCol = (--end(SS))->second;
S.erase(getCol); S.insert(req); PutBack(getCol);
int nx = *upper_bound(begin(v[req]),end(v[req]),i);
SS.erase(--end(SS)); SS.insert({nx,req});
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
3432 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
247 ms |
22676 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
868 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
322 ms |
27728 KB |
Execution killed with signal 11 |
2 |
Runtime error |
332 ms |
27912 KB |
Execution killed with signal 11 |
3 |
Runtime error |
336 ms |
28140 KB |
Execution killed with signal 11 |
4 |
Runtime error |
329 ms |
28352 KB |
Execution killed with signal 11 |
5 |
Runtime error |
313 ms |
28128 KB |
Execution killed with signal 11 |
6 |
Runtime error |
324 ms |
28284 KB |
Execution killed with signal 11 |
7 |
Runtime error |
318 ms |
28164 KB |
Execution killed with signal 11 |
8 |
Runtime error |
378 ms |
28208 KB |
Execution killed with signal 11 |
9 |
Runtime error |
314 ms |
28264 KB |
Execution killed with signal 11 |
10 |
Runtime error |
331 ms |
28180 KB |
Execution killed with signal 11 |