#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
set<int> S; set<pair<int,int>> SS;
vector<int> v[N+1]; int pos[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}); pos[i]=i;
}
for(int i = 0; i < N; i++) {
int req = C[i];
if(S.count(req)){
int nx = *upper_bound(begin(v[req]),end(v[req]),i);
SS.erase({i,req}); SS.insert({nx,req});
for(int j = 0; j < 15; j++) WriteAdvice(1);
}
int getCol = (--end(SS))->second; pos[req] = pos[getCol];
for(int j = 0; j < 15; j++) WriteAdvice((pos[getCol]>>j)&1);
S.erase(getCol); S.insert(req);
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) {
int a[K+1]; for(int i = 0; i < K; i++) a[i] = i;
for(int i = 0; i < N; i++){
int req = GetRequest();
int p = 0; for(int j = 0; j < 15; j++) if(A[15*i+j]) p|=(1<<j);
if(p!=(1<<15)-1) PutBack(a[p]), a[p]=req;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
448 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
2792 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
62 ms |
9040 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
916 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
77 ms |
10640 KB |
Error - advice is too long |
2 |
Incorrect |
75 ms |
10780 KB |
Error - advice is too long |
3 |
Incorrect |
83 ms |
11224 KB |
Error - advice is too long |
4 |
Incorrect |
79 ms |
11136 KB |
Error - advice is too long |
5 |
Incorrect |
79 ms |
11036 KB |
Error - advice is too long |
6 |
Incorrect |
86 ms |
11264 KB |
Error - advice is too long |
7 |
Incorrect |
82 ms |
11128 KB |
Error - advice is too long |
8 |
Incorrect |
78 ms |
11044 KB |
Error - advice is too long |
9 |
Incorrect |
80 ms |
11180 KB |
Error - advice is too long |
10 |
Incorrect |
68 ms |
11096 KB |
Error - advice is too long |