/*************************************
* author: marvinthang *
* created: 04.06.2023 19:41:31 *
*************************************/
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define left ___left
#define right ___right
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define MASK(i) (1LL << (i))
#define BIT(x, i) ((x) >> (i) & 1)
#define __builtin_popcount __builtin_popcountll
#define ALL(v) (v).begin(), (v).end()
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define REPD(i, n) for (int i = (n); i--; )
#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define FORD(i, b, a) for (int i = (b), _a = (a); --i >= _a; )
#define FORE(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORDE(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define scan_op(...) istream & operator >> (istream &in, __VA_ARGS__ &u)
#define print_op(...) ostream & operator << (ostream &out, const __VA_ARGS__ &u)
#ifdef LOCAL
#include "debug.h"
#else
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define DB(...) 23
#define db(...) 23
#define debug(...) 23
#endif
template <class U, class V> scan_op(pair <U, V>) { return in >> u.first >> u.second; }
template <class T> scan_op(vector <T>) { for (size_t i = 0; i < u.size(); ++i) in >> u[i]; return in; }
template <class U, class V> print_op(pair <U, V>) { return out << '(' << u.first << ", " << u.second << ')'; }
template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ")"; else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); }
template <class ...U> print_op(tuple<U...>) { return print_tuple_utils<0, tuple<U...>>(out, u); }
template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream&>::type operator << (ostream &out, const Con &con) { out << '{'; for (__typeof(con.begin()) it = con.begin(); it != con.end(); ++it) out << (it == con.begin() ? "" : ", ") << *it; return out << '}'; }
// end of template
void ComputeAdvice(int *C, int N, int K, int M) {
vector <int> nxt(N), last(N, N), pos(N, -1);
REPD(i, N) {
nxt[i] = last[C[i]];
last[C[i]] = i;
}
set <pair <int, int>> s;
REP(i, K) {
s.insert(make_pair(-last[i], i));
pos[i] = i;
}
REP(i, N) {
if (pos[C[i]] != -1) s.erase(make_pair(-i, C[i]));
else {
int x = s.begin()->se;
REP(i, ceil(log2(K))) WriteAdvice(BIT(pos[x], i));
pos[C[i]] = pos[x];
pos[x] = -1;
s.erase(s.begin());
}
s.insert(make_pair(-nxt[i], C[i]));
}
}
/*************************************
* author: marvinthang *
* created: 04.06.2023 20:07:48 *
*************************************/
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define left ___left
#define right ___right
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define MASK(i) (1LL << (i))
#define BIT(x, i) ((x) >> (i) & 1)
#define __builtin_popcount __builtin_popcountll
#define ALL(v) (v).begin(), (v).end()
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define REPD(i, n) for (int i = (n); i--; )
#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define FORD(i, b, a) for (int i = (b), _a = (a); --i >= _a; )
#define FORE(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORDE(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define scan_op(...) istream & operator >> (istream &in, __VA_ARGS__ &u)
#define print_op(...) ostream & operator << (ostream &out, const __VA_ARGS__ &u)
#ifdef LOCAL
#include "debug.h"
#else
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define DB(...) 23
#define db(...) 23
#define debug(...) 23
#endif
template <class U, class V> scan_op(pair <U, V>) { return in >> u.first >> u.second; }
template <class T> scan_op(vector <T>) { for (size_t i = 0; i < u.size(); ++i) in >> u[i]; return in; }
template <class U, class V> print_op(pair <U, V>) { return out << '(' << u.first << ", " << u.second << ')'; }
template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ")"; else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); }
template <class ...U> print_op(tuple<U...>) { return print_tuple_utils<0, tuple<U...>>(out, u); }
template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream&>::type operator << (ostream &out, const Con &con) { out << '{'; for (__typeof(con.begin()) it = con.begin(); it != con.end(); ++it) out << (it == con.begin() ? "" : ", ") << *it; return out << '}'; }
// end of template
void Assist(unsigned char *A, int N, int K, int R) {
vector <int> pos(N, -1), col(K);
REP(i, K) col[i] = pos[i] = i;
int cur = 0;
REP(i, N) {
int x = GetRequest();
if (pos[x] != -1) continue;
int v = 0;
REP(i, ceil(log2(K))) if (A[cur++]) v ^= MASK(i);
PutBack(col[v]);
pos[col[v]] = -1;
col[v] = x;
pos[x] = v;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
520 KB |
Output is correct |
2 |
Correct |
1 ms |
516 KB |
Output is correct |
3 |
Correct |
2 ms |
536 KB |
Output is correct |
4 |
Correct |
3 ms |
660 KB |
Output is correct |
5 |
Correct |
3 ms |
808 KB |
Output is correct |
6 |
Correct |
7 ms |
976 KB |
Output is correct |
7 |
Correct |
4 ms |
928 KB |
Output is correct |
8 |
Correct |
10 ms |
1124 KB |
Output is correct |
9 |
Correct |
9 ms |
1096 KB |
Output is correct |
10 |
Correct |
8 ms |
992 KB |
Output is correct |
11 |
Correct |
8 ms |
996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1376 KB |
Output is correct |
2 |
Correct |
72 ms |
4168 KB |
Output is correct |
3 |
Correct |
226 ms |
11648 KB |
Output is correct |
4 |
Correct |
135 ms |
7576 KB |
Output is correct |
5 |
Correct |
191 ms |
9520 KB |
Output is correct |
6 |
Correct |
204 ms |
10052 KB |
Output is correct |
7 |
Correct |
192 ms |
9832 KB |
Output is correct |
8 |
Correct |
205 ms |
10224 KB |
Output is correct |
9 |
Correct |
94 ms |
6284 KB |
Output is correct |
10 |
Correct |
174 ms |
9564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
148 ms |
7872 KB |
Output is correct |
2 |
Correct |
191 ms |
9664 KB |
Output is correct |
3 |
Correct |
180 ms |
9616 KB |
Output is correct |
4 |
Correct |
169 ms |
9252 KB |
Output is correct |
5 |
Correct |
143 ms |
8004 KB |
Output is correct |
6 |
Correct |
182 ms |
9596 KB |
Output is correct |
7 |
Correct |
176 ms |
9444 KB |
Output is correct |
8 |
Correct |
246 ms |
12048 KB |
Output is correct |
9 |
Correct |
121 ms |
7628 KB |
Output is correct |
10 |
Correct |
198 ms |
9500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
664 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
202 ms |
9856 KB |
Output is partially correct - 772365 bits used |
2 |
Correct |
183 ms |
9608 KB |
Output is partially correct - 742095 bits used |
3 |
Correct |
196 ms |
9516 KB |
Output is partially correct - 712470 bits used |
4 |
Correct |
190 ms |
9588 KB |
Output is partially correct - 712005 bits used |
5 |
Correct |
187 ms |
9576 KB |
Output is partially correct - 710610 bits used |
6 |
Correct |
226 ms |
9536 KB |
Output is partially correct - 712155 bits used |
7 |
Correct |
187 ms |
9480 KB |
Output is partially correct - 711090 bits used |
8 |
Correct |
183 ms |
9676 KB |
Output is partially correct - 713340 bits used |
9 |
Correct |
185 ms |
9584 KB |
Output is partially correct - 712830 bits used |
10 |
Correct |
239 ms |
12164 KB |
Output is partially correct - 1117620 bits used |