#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
int n,k,m;
bool chk[100000];
int nt[100000];
int pr[100000];
void ComputeAdvice(int *C, int N, int K, int M) {
n=N;
k=K;
m=M;
int cnt=0;
memset(pr,-1,sizeof(pr));
memset(nt,-1,sizeof(nt));
int ind=n;
for(int i=0;i<n;i++) {
if (pr[C[i]]!=-1) {
nt[pr[C[i]]]=i;
}
pr[C[i]]=i;
if (!chk[C[i]]) {
chk[C[i]]=true;
cnt++;
}
if (cnt==k) {
ind=i;
break;
}
}
for(int i=0;i<k;i++) {
if (chk[i]) {
WriteAdvice(1);
}
else {
WriteAdvice(0);
}
}
for(int i=0;i<n;i++) {
if (nt[i]>ind) {
chk[C[i]]=false;
ind++;
cnt--;
while (ind<n) {
if (!chk[C[ind]]) {
cnt++;
}
if (cnt==k) {
break;
}
ind++;
}
}
if (chk[C[i]]) {
WriteAdvice(1);
}
else {
WriteAdvice(0);
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
bool save[100000];
bool isin[100000];
set<int> s;
int n,k,r;
void Assist(unsigned char *A, int N, int K, int R) {
int i;
n=N;
k=K;
r=R;
for(int i=0;i<k;i++) {
isin[i]=true;
if (A[i]=='1') {
save[i]=true;
}
else {
s.insert(i);
}
}
for (i = 0; i < N; i++) {
int req = GetRequest();
if (!isin[req]) {
int now=*s.begin();
s.erase(now);
PutBack(now);
isin[now]=false;
isin[req]=true;
}
save[req]=(A[i+k]==1);
s.erase(req);
if (!save[req]) {
s.insert(req);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1548 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2152 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 |
36 ms |
5040 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 |
3 ms |
1592 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 |
41 ms |
5616 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
48 ms |
5640 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
47 ms |
5988 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
44 ms |
5924 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
47 ms |
6080 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
45 ms |
6004 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
48 ms |
6000 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
47 ms |
5796 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
47 ms |
5808 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
47 ms |
5832 KB |
Output isn't correct - not an optimal way |