#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
#define v vector
#define ii pair<int,int>
#define fi first
#define se second
void ComputeAdvice(int *C, int N, int K, int M) {
int sik = 0;
for(int i=0; i<32; i++){
if(K & (1<<i)) sik = i+1;
}
v<int> lastpos(N,-1);
v<int> nextpos(N);
for(int i=N-1; i>=0; i--){
nextpos[i] = lastpos[C[i]];
lastpos[C[i]] = i;
}
v<int> scaff(N,-1);
priority_queue<ii> pq;
for(int i=0; i<K; i++){
scaff[i]=i;
pq.push({nextpos[i], i});
}
for(int i=0; i<N; i++){
int req = C[i];
if(scaff[req]==-1){
int rem = pq.top().se;
pq.pop();
int k = scaff[rem];
scaff[req] = k;
pq.push({nextpos[req], req});
scaff[rem] = -1;
for(int b=0; b<sik; b++) WriteAdvice((bool)(k & (1<<b)));
}
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
#define v vector
#define ii pair<int,int>
#define fi first
#define se second
void Assist(unsigned char *A, int N, int K, int R) {
int sik = 0;
for(int i=0; i<32; i++){
if(K & (1<<i)) sik = i+1;
}
v<int> scaff(N, -1);
v<int> revscaff(K, -1);
for(int i=0; i<K; i++){
scaff[i]=i;
revscaff[i]=i;
}
int aind=0;
for(int i=0; i<N; i++){
int req = GetRequest();
if(scaff[req]==-1){
int k=0;
for(int j=0; j<sik; j++){
if(A[aind]==1) k |= (1<<j);
aind++;
}
PutBack(revscaff[k]);
scaff[revscaff[k]]=-1;
scaff[req]=k;
revscaff[k]=req;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
1688 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
166 ms |
9080 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
664 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
197 ms |
11460 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
198 ms |
11284 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
185 ms |
11032 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
191 ms |
11156 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
185 ms |
10956 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
201 ms |
11016 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
193 ms |
11180 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
188 ms |
11124 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
186 ms |
11056 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
188 ms |
11320 KB |
Output isn't correct - not an optimal way |