#include<bits/stdc++.h>
#include "advisor.h"
//#include "grader.h"
using namespace std;
void ComputeAdvice(int *C, int n, int k, int m) {
int ls[200005],nx[200005];
priority_queue<pair<int,int> >q;
int ret[200005],sc[200005];
for(int i=0;i<n;i++){
ls[i]=1000000000;
nx[i]=0;
sc[i]=ret[i]=0;
}
for(int i=n-1;i>=0;i--){
nx[i]=ls[C[i]];
ls[C[i]]=i;
// cout<<nx[i]<<" ";
}
// cout<<endl;
for(int i=0;i<k;i++){
q.push({ls[i],i});
sc[i]=1;
}
for(int i=k;i<k+n;i++){//cout<<i<<" "<<C[i-k]<<" "<<sc[C[i-k]]<<endl;
if(sc[C[i-k]]==1) continue;
int a=q.top().first;
int j=q.top().second;
if(j<k) sc[j]=0; else sc[C[i-k]]=0;
q.pop();
sc[C[i-k]]=1;
ret[j]=1;
q.push({nx[i-k],i});
//cout<<i<<" "<<nx[i-k]<<" "<<a<<" "<<j<<" "<<q.size()<<endl;
}//cout<<345;
for(int i=0;i<k+n;i++){
WriteAdvice(ret[i]);
}
}
#include<bits/stdc++.h>
#include "assistant.h"
//#include "grader.h"
using namespace std;
void Assist(unsigned char *A, int n, int k, int r) {
int sc[200005];
queue<int>q;
for(int i=0;i<n;i++){
sc[i]=0;
}
for(int i=0;i<k;i++){
if((int)A[i]==1) {q.push(i);}
sc[i]=1;
}
for(int i=0;i<n;i++){
int a=GetRequest();
if(sc[a]==0)
{
PutBack(q.front());
sc[q.front()]=0;
q.pop();
sc[a]=1;
}
if((int)A[i+k]==1) {q.push(a);}
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:28:13: warning: unused variable 'a' [-Wunused-variable]
int a=q.top().first;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
776 KB |
Output is correct |
2 |
Incorrect |
4 ms |
980 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
1280 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
5760 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1060 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
6768 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
64 ms |
7064 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
64 ms |
7280 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
65 ms |
7024 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
65 ms |
7000 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
72 ms |
7008 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
65 ms |
7008 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
65 ms |
7008 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
65 ms |
7008 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
63 ms |
7008 KB |
Error - Putting back a color that is not on the scaffold |