#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static queue<int> q[100010];
static set<pii> s;
static bool ans[200010];
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0; i<N; i++) {
q[C[i]].em(i);
}
for(int i=0; i<N; i++)
q[i].em(N);
for(int i=0; i<K; i++) {
s.insert(mp(q[i].front(), i));
}
for(int i=0; i<N; i++) {
if(s.begin()->fi == i) {
s.erase(s.begin());
q[C[i]].pop();
s.insert(mp(q[C[i]].front(), i + K));
}
else {
int x = prev(s.end())->se;
ans[x] = true;
s.erase(prev(s.end()));
q[C[i]].pop();
s.insert(mp(q[C[i]].front(), i + K));
}
}
for(int i=0; i<N+K; i++) {
WriteAdvice(ans[i]);
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static int n;
static set<int> t, s;
void Assist(unsigned char *A, int N, int K, int R) {
n = N;
for(int i=0; i<K; i++) {
if(A[i]) s.insert(i);
t.insert(i);
}
for(int i = K; i < N + K; i++) {
int x = GetRequest();
if(t.find(x) == t.end()) {
t.insert(x);
int y = *s.begin();
s.erase(y);
t.erase(y);
PutBack(y);
}
if(A[i]) s.insert(x);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
135168 KB |
Output is correct |
2 |
Correct |
50 ms |
135152 KB |
Output is correct |
3 |
Correct |
52 ms |
135408 KB |
Output is correct |
4 |
Correct |
53 ms |
135408 KB |
Output is correct |
5 |
Correct |
55 ms |
135408 KB |
Output is correct |
6 |
Correct |
59 ms |
135664 KB |
Output is correct |
7 |
Correct |
55 ms |
135408 KB |
Output is correct |
8 |
Correct |
56 ms |
135664 KB |
Output is correct |
9 |
Correct |
55 ms |
135664 KB |
Output is correct |
10 |
Correct |
56 ms |
135664 KB |
Output is correct |
11 |
Correct |
59 ms |
135920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
135664 KB |
Output is correct |
2 |
Correct |
121 ms |
137712 KB |
Output is correct |
3 |
Correct |
239 ms |
142576 KB |
Output is correct |
4 |
Correct |
181 ms |
139248 KB |
Output is correct |
5 |
Correct |
190 ms |
139248 KB |
Output is correct |
6 |
Correct |
213 ms |
139760 KB |
Output is correct |
7 |
Correct |
224 ms |
141040 KB |
Output is correct |
8 |
Correct |
202 ms |
141040 KB |
Output is correct |
9 |
Correct |
159 ms |
139000 KB |
Output is correct |
10 |
Correct |
252 ms |
142320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
207 ms |
139512 KB |
Output is correct |
2 |
Correct |
252 ms |
140784 KB |
Output is correct |
3 |
Correct |
238 ms |
140528 KB |
Output is correct |
4 |
Correct |
245 ms |
140528 KB |
Output is correct |
5 |
Correct |
222 ms |
140024 KB |
Output is correct |
6 |
Correct |
245 ms |
141552 KB |
Output is correct |
7 |
Correct |
231 ms |
141552 KB |
Output is correct |
8 |
Correct |
226 ms |
141808 KB |
Output is correct |
9 |
Correct |
217 ms |
141552 KB |
Output is correct |
10 |
Correct |
238 ms |
141552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
135664 KB |
Output is correct |
2 |
Correct |
60 ms |
135664 KB |
Output is correct |
3 |
Correct |
56 ms |
135408 KB |
Output is correct |
4 |
Correct |
59 ms |
135512 KB |
Output is correct |
5 |
Correct |
55 ms |
135408 KB |
Output is correct |
6 |
Correct |
56 ms |
135424 KB |
Output is correct |
7 |
Correct |
56 ms |
135408 KB |
Output is correct |
8 |
Correct |
56 ms |
135664 KB |
Output is correct |
9 |
Correct |
60 ms |
135664 KB |
Output is correct |
10 |
Correct |
57 ms |
135920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
234 ms |
140272 KB |
Output is correct - 120000 bits used |
2 |
Correct |
228 ms |
140528 KB |
Output is correct - 122000 bits used |
3 |
Correct |
244 ms |
140528 KB |
Output is correct - 125000 bits used |
4 |
Correct |
224 ms |
140944 KB |
Output is correct - 125000 bits used |
5 |
Correct |
253 ms |
140536 KB |
Output is correct - 125000 bits used |
6 |
Correct |
229 ms |
140528 KB |
Output is correct - 125000 bits used |
7 |
Correct |
226 ms |
140544 KB |
Output is correct - 124828 bits used |
8 |
Correct |
229 ms |
140528 KB |
Output is correct - 124910 bits used |
9 |
Correct |
243 ms |
140752 KB |
Output is correct - 125000 bits used |
10 |
Correct |
235 ms |
140528 KB |
Output is correct - 125000 bits used |