#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int N=100006;
int a[N],han[N],mp[N];
bool pas[N],sc[N];
void ComputeAdvice(int *c, int n, int k, int m) {
for (int i=n-1;i>=0;i--){
a[i]=mp[c[i]]-1;
if (mp[c[i]]==0)a[i]=2*n;
mp[c[i]]=i+1;
}
priority_queue<pair<int,int> > pq;
for (int i=0;i<k;i++){
if (mp[i]==0)mp[i]=2*N;
pq.push({mp[i]-1,i});
sc[i]=true;
}
for (int i=0;i<n;i++){\
if (sc[c[i]]){
han[i]=-1;
continue;
}
sc[c[i]]=true;
han[i]=pq.top().second;
sc[pq.top().second]=false;
pq.pop();
pq.push({a[i],c[i]});
}
vector<int> v;
for (int i=n-1;i>=0;i--){
if (pas[c[i]])v.push_back(1);
else v.push_back(0);
if (han[i]!=-1)
pas[han[i]]=false;
pas[c[i]]=true;
}
for (int i=k-1;i>=0;i--){
if (pas[i])v.push_back(1);
else v.push_back(0);
}
reverse(v.begin(),v.end());
for (int i=0;i<v.size();i++){
WriteAdvice(v[i]);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int N=100006;
queue<int> s;
bool onsc[N];
void Assist(unsigned char *A, int n, int k, int R) {
for (int i=0;i<k;i++){
if (!A[i])s.push(i);
onsc[i]=true;
}
for (int i=0;i<n;i++){
int k=GetRequest();
if (onsc[k])continue;
onsc[k]=true;
PutBack(s.front());
onsc[s.front()]=false;
s.pop();
if (!A[i+k])s.push(k);
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:45:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v.size();i++){
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
616 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1136 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
1960 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
5824 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
5824 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
82 ms |
6984 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
79 ms |
6984 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
88 ms |
6984 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
103 ms |
7056 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
91 ms |
7056 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
91 ms |
7056 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
89 ms |
7056 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
81 ms |
7056 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
81 ms |
7056 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
86 ms |
7056 KB |
Error - Putting back a color that is not on the scaffold |