#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
const int maxn=1e5+10;
stack<int> occur[maxn];
int n;
set<pair<int,int> > imam;
set<int> tren;
int prosli[maxn];
int addv[2*maxn];
void ComputeAdvice(int *c, int _n, int k, int m) {
n=_n;
for(int i=n-1;i>=0;i--) occur[c[i]].push(i);
for(int i=0;i<k;i++){
int kad=n+1;
if(!occur[i].empty()) kad=occur[i].top();
imam.emplace(pii(-kad,i));
tren.emplace(i);
}
for(int i=0;i<k;i++) prosli[i]=i;
for(int i=0;i<n+k;i++) addv[i]=1;
for(int i=0;i<n;i++){
occur[c[i]].pop();
prosli[c[i]]=k+i;
if(tren.find(c[i])!=tren.end()) continue;
auto [kad,ind]=*imam.begin();
imam.erase(*imam.begin());
tren.erase(ind);
addv[prosli[ind]]=0;
tren.emplace(c[i]);
if(occur[c[i]].empty()) kad=n+1;
else kad=occur[c[i]].top();
imam.emplace(pii(-kad,c[i]));
}
#ifdef DEBUG
for(int i=0;i<n+k;i++) cout<<addv[i];
cout<<"\n";
#endif
for(int i=0;i<n+k;i++) WriteAdvice(addv[i]);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
void Assist(unsigned char *a, int n, int k, int r) {
set<int> polumrtvi;
for(int i=0;i<k;i++) if(a[i]==0) polumrtvi.emplace(i);
set<int> tren;
for(int i=0;i<k;i++) tren.emplace(i);
for(int i=0;i<n;i++){
int req=GetRequest();
if(tren.find(req)==tren.end()){
assert(!polumrtvi.empty());
PutBack(*polumrtvi.begin());
polumrtvi.erase(polumrtvi.begin());
}
if(a[i+k]==0) polumrtvi.emplace(req);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
67956 KB |
Output is correct |
2 |
Incorrect |
31 ms |
67988 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
68880 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
113 ms |
74880 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
68444 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
127 ms |
75972 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
128 ms |
76276 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
137 ms |
76796 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
126 ms |
76808 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
127 ms |
76792 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
132 ms |
76800 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
135 ms |
76812 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
133 ms |
76816 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
129 ms |
76776 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
129 ms |
76120 KB |
Error - Putting back a color when it is already on the scaffold |