#include "advisor.h"
#include <bits/stdc++.h>
// TODO: check k = 1
using namespace std;
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
const int MAXN = 1e6 + 10;
typedef pair<int, int> pll;
int n, k, F[MAXN];
vector<int> vec[MAXN];
inline int get(int c, int i) {
return *lower_bound(all(vec[c]), i);
}
void ComputeAdvice(int *C, int N, int K, int M) {
n = N, k = K;
for (int i = 0; i < n; i++)
vec[C[i]].push_back(i);
for (int i = 0; i < n; i++)
vec[i].push_back(n);
set<pll> st;
for (int i = 0; i < k; i++)
st.insert(pll(get(i, 0), i));
for (int i = 0; i < n; i++) {
int c = C[i];
if (st.find(pll(get(c, i), c)) != st.end()) {
F[i] = 1;
st.erase(pll(get(c, i), c));
} else {
F[i] = 0;
st.erase(prev(st.end()));
}
st.insert(pll(get(c, i + 1), c));
}
for (int i = 0; i < k; i++)
WriteAdvice(F[vec[i].front()]);
for (int i = 0; i < n; i++)
WriteAdvice(F[get(C[i], i + 1)]);
}
#include "assistant.h"
#include <bits/stdc++.h>
#define X first
#define Y second
#define debug(x) cerr << #x << ": " << x << endl;
#define sep ' '
using namespace std;
typedef pair<int, int> pll;
inline int wtf(int k) {
int ans = 1, res = 0;
while (ans < k)
ans *= 2, res++;
return res;
}
void Assist(unsigned char *A, int N, int K, int R) {
int n = N, k = K;
set<int> st, opt;
for (int i = 0; i < k; i++)
st.insert(i);
for (int i = 0; i < k; i++)
if (int(A[i]) == 0)
opt.insert(i);
for (int i = 0; i < n; i++) {
int c = GetRequest();
if (st.find(c) == st.end()) {
int x = *opt.begin();
PutBack(x);
opt.erase(x);
st.erase(x);
}
st.insert(c);
if (int(A[k + i]) == 0) opt.insert(c);
else if (opt.find(c) != opt.end()) opt.erase(c);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
24008 KB |
Output is correct |
2 |
Correct |
11 ms |
24112 KB |
Output is correct |
3 |
Correct |
12 ms |
24256 KB |
Output is correct |
4 |
Correct |
13 ms |
24276 KB |
Output is correct |
5 |
Correct |
13 ms |
24332 KB |
Output is correct |
6 |
Correct |
16 ms |
24464 KB |
Output is correct |
7 |
Correct |
18 ms |
24544 KB |
Output is correct |
8 |
Correct |
17 ms |
24540 KB |
Output is correct |
9 |
Correct |
18 ms |
24596 KB |
Output is correct |
10 |
Correct |
19 ms |
24808 KB |
Output is correct |
11 |
Correct |
19 ms |
24548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
24964 KB |
Output is correct |
2 |
Correct |
64 ms |
28112 KB |
Output is correct |
3 |
Correct |
150 ms |
35688 KB |
Output is correct |
4 |
Correct |
84 ms |
30520 KB |
Output is correct |
5 |
Correct |
92 ms |
30496 KB |
Output is correct |
6 |
Correct |
129 ms |
31560 KB |
Output is correct |
7 |
Correct |
133 ms |
33460 KB |
Output is correct |
8 |
Correct |
107 ms |
33076 KB |
Output is correct |
9 |
Correct |
79 ms |
31132 KB |
Output is correct |
10 |
Correct |
175 ms |
34908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
108 ms |
31944 KB |
Output is correct |
2 |
Correct |
138 ms |
34004 KB |
Output is correct |
3 |
Correct |
156 ms |
34352 KB |
Output is correct |
4 |
Correct |
139 ms |
34032 KB |
Output is correct |
5 |
Correct |
136 ms |
33552 KB |
Output is correct |
6 |
Correct |
142 ms |
34284 KB |
Output is correct |
7 |
Correct |
153 ms |
34240 KB |
Output is correct |
8 |
Correct |
144 ms |
34156 KB |
Output is correct |
9 |
Correct |
122 ms |
34384 KB |
Output is correct |
10 |
Correct |
141 ms |
34276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
24524 KB |
Output is correct |
2 |
Correct |
16 ms |
24536 KB |
Output is correct |
3 |
Correct |
16 ms |
24352 KB |
Output is correct |
4 |
Correct |
15 ms |
24336 KB |
Output is correct |
5 |
Correct |
17 ms |
24340 KB |
Output is correct |
6 |
Correct |
17 ms |
24404 KB |
Output is correct |
7 |
Correct |
17 ms |
24532 KB |
Output is correct |
8 |
Correct |
18 ms |
24540 KB |
Output is correct |
9 |
Correct |
16 ms |
24632 KB |
Output is correct |
10 |
Correct |
18 ms |
24932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
144 ms |
33104 KB |
Output is correct - 120000 bits used |
2 |
Correct |
133 ms |
33432 KB |
Output is correct - 122000 bits used |
3 |
Correct |
142 ms |
33848 KB |
Output is correct - 125000 bits used |
4 |
Correct |
140 ms |
33776 KB |
Output is correct - 125000 bits used |
5 |
Correct |
140 ms |
33824 KB |
Output is correct - 125000 bits used |
6 |
Correct |
141 ms |
33920 KB |
Output is correct - 125000 bits used |
7 |
Correct |
138 ms |
33860 KB |
Output is correct - 124828 bits used |
8 |
Correct |
141 ms |
33876 KB |
Output is correct - 124910 bits used |
9 |
Correct |
151 ms |
33764 KB |
Output is correct - 125000 bits used |
10 |
Correct |
122 ms |
33768 KB |
Output is correct - 125000 bits used |