#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#define pub push_back
#define pob pop_back
#define mp make_pair
#define sec second
using namespace std;
//#include"grader.cpp"
const int mod=1e9+7;
//void WriteAdvice(unsigned char a) {};
#include"advisor.h"
void ComputeAdvice(int *C, int N, int K, int M) {
static bool kta[200000]={};
int i,j;
priority_queue<pair<int,int>>que;
//次いる日、入れたときの番号
vector<vector<int>>need(N);
for(i=0;i<N;i++){need[i].pub(mod);}
for(i=N-1;i>=0;i--){need[C[i]].pub(i);}
static bool tna[100000]={};
for(i=0;i<K;i++){que.push(mp(need[i].back(),i));tna[i]=1;}
for(i=0;i<N;i++){
int use=C[i];
need[use].pob();
if(!tna[use]){
pair<int,int> ksu;
while(-1){
ksu=que.top();que.pop();
int ter;
if(ksu.sec<K){ter=ksu.sec;}else{ter=C[ksu.sec-K];}
if(tna[ter]){kta[ksu.sec]=1;tna[ter]=0;break;}
}
tna[use]=1;
}
que.push(mp(need[use].back(),i+K));
}
for(i=0;i<K+N;i++){WriteAdvice(kta[i]);}
}
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#define pub push_back
#define pob pop_back
#define mp make_pair
#define sec second
using namespace std;
#include "assistant.h"
void Assist(unsigned char *A, int N, int K, int R) {
int i;
deque<int>iran;
static bool aru[100000]={};
for(i=0;i<K;i++){if(A[i]){iran.pub(i);}aru[i]=1;}
for(i=0;i<N;i++) {
int req=GetRequest();
if(!aru[req]){PutBack(iran.back());aru[iran.back()]=0;iran.pob();}
if(A[i+K]){iran.pub(req);}
aru[req]=1;
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:16:8: warning: unused variable 'j' [-Wunused-variable]
int i,j;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
752 KB |
Output is correct |
2 |
Correct |
6 ms |
1036 KB |
Output is correct |
3 |
Correct |
7 ms |
1048 KB |
Output is correct |
4 |
Correct |
10 ms |
1648 KB |
Output is correct |
5 |
Correct |
8 ms |
1864 KB |
Output is correct |
6 |
Correct |
13 ms |
1944 KB |
Output is correct |
7 |
Correct |
9 ms |
2520 KB |
Output is correct |
8 |
Correct |
10 ms |
2520 KB |
Output is correct |
9 |
Correct |
9 ms |
2520 KB |
Output is correct |
10 |
Correct |
11 ms |
2568 KB |
Output is correct |
11 |
Correct |
10 ms |
2568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
3200 KB |
Output is correct |
2 |
Correct |
63 ms |
9920 KB |
Output is correct |
3 |
Correct |
165 ms |
18136 KB |
Output is correct |
4 |
Correct |
124 ms |
18136 KB |
Output is correct |
5 |
Correct |
134 ms |
18864 KB |
Output is correct |
6 |
Correct |
193 ms |
20776 KB |
Output is correct |
7 |
Correct |
195 ms |
22792 KB |
Output is correct |
8 |
Correct |
166 ms |
22792 KB |
Output is correct |
9 |
Correct |
99 ms |
24168 KB |
Output is correct |
10 |
Correct |
145 ms |
26064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
110 ms |
26064 KB |
Output is correct |
2 |
Correct |
139 ms |
27208 KB |
Output is correct |
3 |
Correct |
171 ms |
28688 KB |
Output is correct |
4 |
Correct |
157 ms |
29824 KB |
Output is correct |
5 |
Correct |
156 ms |
31216 KB |
Output is correct |
6 |
Correct |
138 ms |
31840 KB |
Output is correct |
7 |
Correct |
175 ms |
33000 KB |
Output is correct |
8 |
Correct |
227 ms |
33000 KB |
Output is correct |
9 |
Correct |
144 ms |
36576 KB |
Output is correct |
10 |
Correct |
184 ms |
36576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
36576 KB |
Output is correct |
2 |
Correct |
9 ms |
36576 KB |
Output is correct |
3 |
Correct |
10 ms |
36576 KB |
Output is correct |
4 |
Correct |
12 ms |
36576 KB |
Output is correct |
5 |
Correct |
12 ms |
36576 KB |
Output is correct |
6 |
Correct |
10 ms |
36576 KB |
Output is correct |
7 |
Correct |
11 ms |
36576 KB |
Output is correct |
8 |
Correct |
9 ms |
36576 KB |
Output is correct |
9 |
Correct |
10 ms |
36576 KB |
Output is correct |
10 |
Correct |
12 ms |
36576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
167 ms |
37000 KB |
Output is correct - 120000 bits used |
2 |
Correct |
169 ms |
37008 KB |
Output is correct - 122000 bits used |
3 |
Correct |
146 ms |
37008 KB |
Output is correct - 125000 bits used |
4 |
Correct |
129 ms |
37008 KB |
Output is correct - 125000 bits used |
5 |
Correct |
141 ms |
37008 KB |
Output is correct - 125000 bits used |
6 |
Correct |
155 ms |
37416 KB |
Output is correct - 125000 bits used |
7 |
Correct |
161 ms |
37416 KB |
Output is correct - 124828 bits used |
8 |
Correct |
151 ms |
37416 KB |
Output is correct - 124910 bits used |
9 |
Correct |
137 ms |
37416 KB |
Output is correct - 125000 bits used |
10 |
Correct |
174 ms |
37416 KB |
Output is correct - 125000 bits used |