#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);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
776 KB |
Output is correct |
2 |
Correct |
2 ms |
932 KB |
Output is correct |
3 |
Correct |
3 ms |
2112 KB |
Output is correct |
4 |
Correct |
5 ms |
4864 KB |
Output is correct |
5 |
Correct |
8 ms |
7424 KB |
Output is correct |
6 |
Correct |
9 ms |
7424 KB |
Output is correct |
7 |
Correct |
9 ms |
7680 KB |
Output is correct |
8 |
Correct |
10 ms |
7680 KB |
Output is correct |
9 |
Correct |
10 ms |
7680 KB |
Output is correct |
10 |
Correct |
11 ms |
7680 KB |
Output is correct |
11 |
Correct |
9 ms |
7680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
14592 KB |
Output is correct |
2 |
Correct |
100 ms |
70896 KB |
Output is correct |
3 |
Correct |
257 ms |
143088 KB |
Output is correct |
4 |
Correct |
176 ms |
139544 KB |
Output is correct |
5 |
Correct |
183 ms |
139504 KB |
Output is correct |
6 |
Correct |
215 ms |
140016 KB |
Output is correct |
7 |
Correct |
247 ms |
141552 KB |
Output is correct |
8 |
Correct |
195 ms |
121192 KB |
Output is correct |
9 |
Correct |
157 ms |
136944 KB |
Output is correct |
10 |
Correct |
265 ms |
142832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
207 ms |
114168 KB |
Output is correct |
2 |
Correct |
267 ms |
142064 KB |
Output is correct |
3 |
Correct |
246 ms |
142064 KB |
Output is correct |
4 |
Correct |
257 ms |
142064 KB |
Output is correct |
5 |
Correct |
243 ms |
140016 KB |
Output is correct |
6 |
Correct |
252 ms |
142064 KB |
Output is correct |
7 |
Correct |
249 ms |
142320 KB |
Output is correct |
8 |
Correct |
251 ms |
142064 KB |
Output is correct |
9 |
Correct |
248 ms |
142320 KB |
Output is correct |
10 |
Correct |
252 ms |
142064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
6400 KB |
Output is correct |
2 |
Correct |
10 ms |
7680 KB |
Output is correct |
3 |
Correct |
9 ms |
7680 KB |
Output is correct |
4 |
Correct |
7 ms |
7424 KB |
Output is correct |
5 |
Correct |
8 ms |
7680 KB |
Output is correct |
6 |
Correct |
10 ms |
7680 KB |
Output is correct |
7 |
Correct |
9 ms |
7680 KB |
Output is correct |
8 |
Correct |
9 ms |
7680 KB |
Output is correct |
9 |
Correct |
9 ms |
7680 KB |
Output is correct |
10 |
Correct |
11 ms |
7936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
236 ms |
141808 KB |
Output is correct - 120000 bits used |
2 |
Correct |
241 ms |
141808 KB |
Output is correct - 122000 bits used |
3 |
Correct |
242 ms |
142320 KB |
Output is correct - 125000 bits used |
4 |
Correct |
241 ms |
142064 KB |
Output is correct - 125000 bits used |
5 |
Correct |
245 ms |
142064 KB |
Output is correct - 125000 bits used |
6 |
Correct |
240 ms |
142064 KB |
Output is correct - 125000 bits used |
7 |
Correct |
242 ms |
141832 KB |
Output is correct - 124828 bits used |
8 |
Correct |
242 ms |
142064 KB |
Output is correct - 124910 bits used |
9 |
Correct |
274 ms |
142320 KB |
Output is correct - 125000 bits used |
10 |
Correct |
234 ms |
142064 KB |
Output is correct - 125000 bits used |