#include<bits/stdc++.h>
#include "advisor.h"
//#include "grader.h"
using namespace std;
void ComputeAdvice(int *C, int n, int k, int m) {//cout<<345;
int ls[2000005],nx[200005];
set<pair<int,int> >q;
int ret[200005],sc[200005];
for(int i=0;i<=200000;i++){
ls[i]=100000000;
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.insert({-ls[i],i});
sc[i]=1;
}
for(int i=k;i<k+n;i++){
int a=-q.begin()->first;
int j=q.begin()->second;
if(sc[C[i-k]]==1) {q.erase(q.lower_bound({-(i-k),0}));q.insert({-nx[i-k],i});/**/continue;}
q.erase(q.begin());
q.insert({-nx[i-k],i});
if(j<k) sc[j]=0; else sc[C[i-k]]=0;
sc[C[i-k]]=1;
ret[j]=1;
}
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)
{
if(q.size()==0)PutBack(0);
else
{
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.begin()->first;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6912 KB |
Output is correct |
2 |
Correct |
6 ms |
6912 KB |
Output is correct |
3 |
Correct |
7 ms |
7168 KB |
Output is correct |
4 |
Runtime error |
11 ms |
7040 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
15 ms |
7296 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
10808 KB |
Output is correct |
2 |
Correct |
93 ms |
12016 KB |
Output is correct |
3 |
Correct |
94 ms |
12016 KB |
Output is correct |
4 |
Correct |
93 ms |
11800 KB |
Output is correct |
5 |
Runtime error |
55 ms |
9592 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7168 KB |
Output is correct |
2 |
Correct |
10 ms |
7168 KB |
Output is correct |
3 |
Runtime error |
11 ms |
7040 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
52 ms |
9568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Correct |
89 ms |
11760 KB |
Output is correct - 122000 bits used |
3 |
Correct |
93 ms |
12016 KB |
Output is correct - 125000 bits used |
4 |
Correct |
96 ms |
12016 KB |
Output is correct - 125000 bits used |
5 |
Correct |
92 ms |
11976 KB |
Output is correct - 125000 bits used |
6 |
Correct |
93 ms |
12016 KB |
Output is correct - 125000 bits used |
7 |
Correct |
92 ms |
12016 KB |
Output is correct - 124828 bits used |
8 |
Correct |
92 ms |
11960 KB |
Output is correct - 124910 bits used |
9 |
Correct |
93 ms |
12184 KB |
Output is correct - 125000 bits used |
10 |
Runtime error |
50 ms |
9980 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |