#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,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 |
Incorrect |
0 ms |
508 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
1512 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
148 ms |
8044 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
644 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
219 ms |
10392 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
197 ms |
10244 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
195 ms |
9968 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
193 ms |
9820 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
211 ms |
9904 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
181 ms |
9808 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
181 ms |
9892 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
188 ms |
9924 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
181 ms |
9788 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
183 ms |
9828 KB |
Output isn't correct - not an optimal way |