#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;
pair<int,int> colores[100001];
int andamio[100001];
queue<int> libres;
void ComputeAdvice(int *C, int N, int K, int M){
for(int i=0;i<N;i++){
colores[i]={-1,-1};
}
for(int i=0;i<N;i++){
if(i<K){
andamio[i]=i;
colores[i].second=i;
}
colores[C[i]].first=i;
}
for(int i=0;i<K;i++){
if(colores[andamio[i]].first==-1) {
WriteAdvice(0);
libres.push(i);
}
else {
WriteAdvice(1);
}
}
for(int i=0;i<N;i++){
if(colores[C[i]].second==-1){
int pos=0;
if(libres.size()>0){
pos=libres.front();
libres.pop();
}
colores[C[i]].second=pos;
andamio[pos]=C[i];
colores[andamio[pos]].second=-1;
}
if(colores[C[i]].first==i){
libres.push(colores[C[i]].second);
WriteAdvice(0);
}
else WriteAdvice(1);
}
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
queue<int> lib;
int an[100001];
int col[100001];
void Assist(unsigned char *A, int N, int K, int R){
for(int i=0;i<N;i++){
if(i<K){
an[i]=i;
col[i]=i;
if(A[i]==0) lib.push(i);
}
else col[i]=-1;
}
for(int i=0;i<N;i++){
int c=GetRequest();
if(col[c]==-1){
int pos=0;
if(lib.size()>0){
pos=lib.front();
lib.pop();
}
PutBack(an[pos]);
col[an[pos]]=-1;
col[c]=pos;
an[pos]=c;
}
if(A[i+K]==0) lib.push(col[c]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
524 KB |
Output is correct |
3 |
Correct |
2 ms |
648 KB |
Output is correct |
4 |
Incorrect |
2 ms |
816 KB |
Output isn't correct - not an optimal way |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
980 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
4000 KB |
Output is correct |
2 |
Correct |
54 ms |
6004 KB |
Output is correct |
3 |
Correct |
51 ms |
6084 KB |
Output is correct |
4 |
Correct |
53 ms |
6084 KB |
Output is correct |
5 |
Incorrect |
57 ms |
5876 KB |
Output isn't correct - not an optimal way |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
796 KB |
Output is correct |
2 |
Correct |
3 ms |
836 KB |
Output is correct |
3 |
Correct |
3 ms |
824 KB |
Output is correct |
4 |
Incorrect |
3 ms |
808 KB |
Output isn't correct - not an optimal way |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
4844 KB |
Output isn't correct - not an optimal way |
2 |
Correct |
52 ms |
4780 KB |
Output is correct - 122000 bits used |
3 |
Correct |
55 ms |
5004 KB |
Output is correct - 125000 bits used |
4 |
Correct |
62 ms |
4904 KB |
Output is correct - 125000 bits used |
5 |
Correct |
50 ms |
4932 KB |
Output is correct - 125000 bits used |
6 |
Correct |
49 ms |
4768 KB |
Output is correct - 125000 bits used |
7 |
Correct |
51 ms |
4824 KB |
Output is correct - 124828 bits used |
8 |
Correct |
57 ms |
4864 KB |
Output is correct - 124910 bits used |
9 |
Correct |
55 ms |
4896 KB |
Output is correct - 125000 bits used |
10 |
Correct |
49 ms |
4900 KB |
Output is correct - 125000 bits used |