//#include "advisor.h"
#include<bits/stdc++.h>
#define FOR(i,a) for(int i=0;i<a;i++)
#define FOR1(i,a) for(int i=1;i<=a;i++)
#define db(a) printf("<%d> ",a)
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb emplace_back
#define p emplace
#define ii pair<int,int>
#define ll long long
#define rf() freopen("_working/input.in","r",stdin)
#define pf() freopen("_working/output.out","w+",stdout)
using namespace std;
const int INF=1e9;
void WriteAdvice(unsigned char a);
void ComputeAdvice(int *C, int N, int K, int M){
queue<int> nxt[N];
int t[N+K];
int now[N];
FOR(i,N){
nxt[C[i]].p(i);
now[i]=-1;
}
set<ii> s;
FOR(i,N){
if(i<K){
now[i]=i;
s.p(nxt[i].empty()?INF:nxt[i].front(),i);}
if(!nxt[i].empty())nxt[i].pop();
}
FOR(i,N+K)t[i]=0;
FOR(i,N){
if(now[C[i]]!=-1){
t[now[C[i]]]=1;
now[C[i]]=i+K;
s.erase(mp(i,C[i]));
s.p(nxt[C[i]].empty()?INF:nxt[C[i]].front(),C[i]);
if(!nxt[C[i]].empty())nxt[C[i]].pop();
continue;
}
else{
// printf("<%d>\n",i);
// printf("erase %d nxt : %d\n",s.rbegin()->s,s.rbegin()->f);
now[s.rbegin()->s]=-1;
s.erase(*s.rbegin());
now[C[i]]=i+K;
s.p(nxt[C[i]].empty()?INF:nxt[C[i]].front(),C[i]);
// printf("insert %d at %d\n",C[i],nxt[C[i]].empty()?INF:nxt[C[i]].front());
if(!nxt[C[i]].empty())nxt[C[i]].pop();
continue;
}
}
FOR(i,N+K){
//printf("%d ",t[i]);
WriteAdvice(t[i]?1:0);
}
}
//#include "assistant.h"
#include<bits/stdc++.h>
#define FOR(i,a) for(int i=0;i<a;i++)
#define FOR1(i,a) for(int i=1;i<=a;i++)
#define db(a) printf("<%d> ",a)
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb emplace_back
#define p emplace
#define ii pair<int,int>
#define ll long long
#define rf() freopen("_working/input.in","r",stdin)
#define pf() freopen("_working/output.out","w+",stdout)
using namespace std;
//const int INF=1e9;
void PutBack(int T);
int GetRequest();
void Assist(unsigned char *A, int N, int K, int R){
queue<int> erase;
set<int> sca;
FOR(i,K){
if(A[i]==0){
erase.p(i);
}
sca.insert(i);
}
FOR(i,N){
int a = GetRequest();
if(sca.find(a)==sca.end()){
sca.erase(erase.front());
PutBack(erase.front());
erase.pop();
}
if(A[i+K]==0)erase.push(a);
sca.insert(a);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
776 KB |
Output is correct |
2 |
Correct |
1 ms |
904 KB |
Output is correct |
3 |
Correct |
3 ms |
2048 KB |
Output is correct |
4 |
Correct |
5 ms |
4864 KB |
Output is correct |
5 |
Correct |
7 ms |
7680 KB |
Output is correct |
6 |
Correct |
9 ms |
7680 KB |
Output is correct |
7 |
Correct |
9 ms |
7680 KB |
Output is correct |
8 |
Correct |
11 ms |
7680 KB |
Output is correct |
9 |
Correct |
11 ms |
7680 KB |
Output is correct |
10 |
Correct |
12 ms |
7936 KB |
Output is correct |
11 |
Correct |
12 ms |
7680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
14848 KB |
Output is correct |
2 |
Correct |
106 ms |
71416 KB |
Output is correct |
3 |
Correct |
287 ms |
144368 KB |
Output is correct |
4 |
Correct |
182 ms |
140528 KB |
Output is correct |
5 |
Correct |
196 ms |
140784 KB |
Output is correct |
6 |
Correct |
221 ms |
141296 KB |
Output is correct |
7 |
Correct |
261 ms |
142592 KB |
Output is correct |
8 |
Correct |
213 ms |
122096 KB |
Output is correct |
9 |
Correct |
176 ms |
138224 KB |
Output is correct |
10 |
Correct |
290 ms |
143856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
115184 KB |
Output is correct |
2 |
Correct |
267 ms |
143192 KB |
Output is correct |
3 |
Correct |
245 ms |
143352 KB |
Output is correct |
4 |
Correct |
246 ms |
143168 KB |
Output is correct |
5 |
Correct |
241 ms |
141296 KB |
Output is correct |
6 |
Correct |
247 ms |
143344 KB |
Output is correct |
7 |
Correct |
253 ms |
143344 KB |
Output is correct |
8 |
Correct |
235 ms |
143344 KB |
Output is correct |
9 |
Correct |
242 ms |
143344 KB |
Output is correct |
10 |
Correct |
256 ms |
143344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
6400 KB |
Output is correct |
2 |
Correct |
10 ms |
7704 KB |
Output is correct |
3 |
Correct |
8 ms |
7680 KB |
Output is correct |
4 |
Correct |
11 ms |
7680 KB |
Output is correct |
5 |
Correct |
9 ms |
7744 KB |
Output is correct |
6 |
Correct |
9 ms |
7680 KB |
Output is correct |
7 |
Correct |
10 ms |
7712 KB |
Output is correct |
8 |
Correct |
11 ms |
7936 KB |
Output is correct |
9 |
Correct |
13 ms |
7744 KB |
Output is correct |
10 |
Correct |
13 ms |
7936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
267 ms |
142832 KB |
Output is correct - 120000 bits used |
2 |
Correct |
258 ms |
143088 KB |
Output is correct - 122000 bits used |
3 |
Correct |
248 ms |
143344 KB |
Output is correct - 125000 bits used |
4 |
Correct |
258 ms |
143344 KB |
Output is correct - 125000 bits used |
5 |
Correct |
275 ms |
143344 KB |
Output is correct - 125000 bits used |
6 |
Correct |
256 ms |
143384 KB |
Output is correct - 125000 bits used |
7 |
Correct |
251 ms |
143088 KB |
Output is correct - 124828 bits used |
8 |
Correct |
259 ms |
143216 KB |
Output is correct - 124910 bits used |
9 |
Correct |
254 ms |
143216 KB |
Output is correct - 125000 bits used |
10 |
Correct |
257 ms |
143344 KB |
Output is correct - 125000 bits used |