#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i = 0; i < N; i++)
for(int j = 0; j < 20; j++)
WriteAdvice((C[i]>>j)&1);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
int C[N+1]; vector<int> v[N+1];
for(int i = 0; i < N; i++) C[i]=0;
for(int i = 0; i < R; i++)
if(A[i]) C[i/20] |= (1<<(i%20));
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});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
508 KB |
Output is correct |
2 |
Correct |
1 ms |
520 KB |
Output is correct |
3 |
Correct |
4 ms |
768 KB |
Output is correct |
4 |
Correct |
10 ms |
1180 KB |
Output is correct |
5 |
Incorrect |
1 ms |
668 KB |
Error - advice is too long |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
2744 KB |
Output is correct |
2 |
Correct |
181 ms |
11616 KB |
Output is correct |
3 |
Correct |
395 ms |
24904 KB |
Output is correct |
4 |
Correct |
337 ms |
21584 KB |
Output is correct |
5 |
Correct |
358 ms |
21664 KB |
Output is correct |
6 |
Correct |
358 ms |
22188 KB |
Output is correct |
7 |
Correct |
381 ms |
23472 KB |
Output is correct |
8 |
Correct |
318 ms |
20644 KB |
Output is correct |
9 |
Correct |
327 ms |
21636 KB |
Output is correct |
10 |
Correct |
410 ms |
24360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
2304 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
508 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
2708 KB |
Error - advice is too long |
2 |
Incorrect |
13 ms |
2668 KB |
Error - advice is too long |
3 |
Incorrect |
13 ms |
2708 KB |
Error - advice is too long |
4 |
Incorrect |
13 ms |
2700 KB |
Error - advice is too long |
5 |
Incorrect |
14 ms |
2704 KB |
Error - advice is too long |
6 |
Incorrect |
13 ms |
2728 KB |
Error - advice is too long |
7 |
Incorrect |
16 ms |
2700 KB |
Error - advice is too long |
8 |
Incorrect |
19 ms |
2680 KB |
Error - advice is too long |
9 |
Incorrect |
15 ms |
2700 KB |
Error - advice is too long |
10 |
Incorrect |
14 ms |
2724 KB |
Error - advice is too long |