#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5 + 10;
//#define debug(...) fprintf(stderr, __VA_ARGS__)
#define debug(...)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
#warning static (advisor)
static int subtask;
static set<pii> st; //pii(when we neet i, i) -- you remove GREATEST of them.
static bool has[MAXN];
static vector<int> inds[MAXN];
void ComputeAdvice (int *C, int N, int K, int M) {
debug("--------------------------------BEGIN ADVISOR-----------------------------------\n");
//let's just implement -- get the bits
for (int i = 0; i < N; i++) {
inds[i].push_back(N);
}
for (int i = N - 1; i >= 0; i--) {
inds[C[i]].push_back(i);
}
for (int i = 0; i < K; i++) {
has[i] = true;
st.emplace(inds[i].back(), i);
}
vector<int> ans;
for (int i = 0; i < N; i++) {
inds[C[i]].pop_back();
if (has[C[i]]) {
st.erase(pii(inds[C[i]].back(), C[i]));
st.insert(pii(inds[C[i]].back(), C[i]));
debug("No action\n");
ans.push_back(N); //this is bad
continue;
}
//remove one
auto it = --st.end();
pii tp = *it;
st.erase(it);
has[tp.se] = false;
debug("Put %d away, put %d in.\n", tp.se, C[i]);
ans.push_back(tp.se);
st.insert(pii(inds[C[i]].back(), C[i]));
//add C[i]
has[C[i]] = true;
}
//the end of computing.
int logn = 31 - __builtin_clz(N);
for (int x : ans) {
debug("-----x = %d-------\n", x);
for (int i = logn; i >= 0; i--) {
WriteAdvice((x >> i) & 1);
debug("AA %d\n", (x >> i) & 1);
}
}
debug("--------------------------------DONE WITH THE ADVISOR-----------------------------------\n");
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//#define debug(...) fprintf(stderr, __VA_ARGS__)
#define debug(...)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
#warning static (assistant)
static int subtask;
void Assist (unsigned char *A, int N, int K, int R) {
debug("--------------------------------BEGIN ASSISTANT-----------------------------------\n");
int logn = 31 - __builtin_clz(N);
for (int i = 0; i < N; i++) {
GetRequest();
int x = 0;
for (int j = 0; j <= logn; j++) {
int pos = (logn + 1) * i + j;
debug("Advice = %d\n", A[pos]);
x = 2 * x + A[pos];
}
if (x != N) {
debug("put %d away\n", x);
PutBack(x);
}
}
debug("--------------------------------DONE WITH THE ASSISTANT-----------------------------------\n");
}
Compilation message
advisor.cpp:17:2: warning: #warning static (advisor) [-Wcpp]
#warning static (advisor)
^~~~~~~
advisor.cpp:19:12: warning: 'subtask' defined but not used [-Wunused-variable]
static int subtask;
^~~~~~~
assistant.cpp:16:2: warning: #warning static (assistant) [-Wcpp]
#warning static (assistant)
^~~~~~~
assistant.cpp:18:12: warning: 'subtask' defined but not used [-Wunused-variable]
static int subtask;
^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
5360 KB |
Output is correct |
2 |
Correct |
9 ms |
5440 KB |
Output is correct |
3 |
Correct |
12 ms |
6296 KB |
Output is correct |
4 |
Correct |
20 ms |
6600 KB |
Output is correct |
5 |
Correct |
34 ms |
7032 KB |
Output is correct |
6 |
Correct |
25 ms |
7240 KB |
Output is correct |
7 |
Correct |
31 ms |
7800 KB |
Output is correct |
8 |
Correct |
24 ms |
7800 KB |
Output is correct |
9 |
Correct |
24 ms |
7800 KB |
Output is correct |
10 |
Correct |
26 ms |
7800 KB |
Output is correct |
11 |
Correct |
33 ms |
7840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
9168 KB |
Output is correct |
2 |
Correct |
224 ms |
20264 KB |
Output is correct |
3 |
Correct |
641 ms |
34120 KB |
Output is correct |
4 |
Correct |
513 ms |
34120 KB |
Output is correct |
5 |
Correct |
459 ms |
34120 KB |
Output is correct |
6 |
Correct |
519 ms |
34120 KB |
Output is correct |
7 |
Correct |
559 ms |
38056 KB |
Output is correct |
8 |
Correct |
487 ms |
38056 KB |
Output is correct |
9 |
Correct |
517 ms |
38056 KB |
Output is correct |
10 |
Correct |
572 ms |
42776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
476 ms |
42776 KB |
Output is correct |
2 |
Incorrect |
215 ms |
42776 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
42776 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
465 ms |
44792 KB |
Output is partially correct - 1700000 bits used |
2 |
Partially correct |
509 ms |
46184 KB |
Output is partially correct - 1700000 bits used |
3 |
Partially correct |
535 ms |
48008 KB |
Output is partially correct - 1700000 bits used |
4 |
Partially correct |
570 ms |
49008 KB |
Output is partially correct - 1700000 bits used |
5 |
Partially correct |
495 ms |
50424 KB |
Output is partially correct - 1700000 bits used |
6 |
Partially correct |
484 ms |
51424 KB |
Output is partially correct - 1700000 bits used |
7 |
Partially correct |
532 ms |
52768 KB |
Output is partially correct - 1697263 bits used |
8 |
Partially correct |
538 ms |
53904 KB |
Output is partially correct - 1700000 bits used |
9 |
Partially correct |
494 ms |
55056 KB |
Output is partially correct - 1700000 bits used |
10 |
Partially correct |
558 ms |
55056 KB |
Output is partially correct - 1700000 bits used |