#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((pos[req]>>j)&1);
continue;
}
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(a[p]!=req) PutBack(a[p]), a[p]=req;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
576 KB |
Output is correct |
2 |
Correct |
2 ms |
520 KB |
Output is correct |
3 |
Correct |
5 ms |
804 KB |
Output is correct |
4 |
Correct |
8 ms |
1136 KB |
Output is correct |
5 |
Incorrect |
2 ms |
924 KB |
Error - advice is too long |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
2464 KB |
Output is correct |
2 |
Correct |
159 ms |
10032 KB |
Output is correct |
3 |
Incorrect |
348 ms |
21988 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
259 ms |
16860 KB |
Output is correct |
2 |
Correct |
355 ms |
20828 KB |
Output is correct |
3 |
Correct |
336 ms |
21024 KB |
Output is correct |
4 |
Correct |
337 ms |
21076 KB |
Output is correct |
5 |
Correct |
373 ms |
20448 KB |
Output is correct |
6 |
Correct |
338 ms |
21020 KB |
Output is correct |
7 |
Correct |
333 ms |
20996 KB |
Output is correct |
8 |
Correct |
322 ms |
21052 KB |
Output is correct |
9 |
Correct |
300 ms |
21184 KB |
Output is correct |
10 |
Correct |
332 ms |
20968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
912 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
357 ms |
20476 KB |
Output is partially correct - 1500000 bits used |
2 |
Correct |
348 ms |
20792 KB |
Output is partially correct - 1500000 bits used |
3 |
Correct |
369 ms |
20892 KB |
Output is partially correct - 1500000 bits used |
4 |
Correct |
328 ms |
20996 KB |
Output is partially correct - 1500000 bits used |
5 |
Correct |
325 ms |
20916 KB |
Output is partially correct - 1500000 bits used |
6 |
Correct |
334 ms |
21008 KB |
Output is partially correct - 1500000 bits used |
7 |
Correct |
326 ms |
20952 KB |
Output is partially correct - 1497585 bits used |
8 |
Correct |
383 ms |
20988 KB |
Output is partially correct - 1500000 bits used |
9 |
Correct |
336 ms |
21072 KB |
Output is partially correct - 1500000 bits used |
10 |
Correct |
329 ms |
21140 KB |
Output is partially correct - 1500000 bits used |