#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
const int MAXN = 100005;
void ComputeAdvice(int *C, int N, int K, int M)
{
int h[MAXN] = {};
int u[MAXN] = {};
int d[MAXN] = {};
int ans[MAXN] = {};
for (int i = 0; i < N; ++i)
u[i] = N;
for (int i = N - 1; i >= 0; --i)
{
h[i] = u[C[i]];
u[C[i]] = i;
}
set<int> s;
for (int i = 0; i < K; ++i)
s.insert(i);
set<pair<int, int> > ss;
for (int i = 0; i < K; ++i)
ss.insert(m_p(u[i], i));
for (int i = 0; i < K; ++i)
d[i] = i + 1;
for (int i = 0; i < N; ++i)
{
if (s.find(C[i]) != s.end())
{
continue;
}
int x = (--ss.end())->se;
ss.erase((--ss.end()));
ss.insert(m_p(h[i], C[i]));
s.erase(x);
s.insert(C[i]);
ans[i] = d[x];
d[C[i]] = d[x];
}
int l = 0;
while ((1 << l) < K)
++l;
++l;
for (int i = 0; i < N; ++i)
{
if (ans[i] == 0)
continue;
--ans[i];
for (int j = 0; j < l; ++j)
{
if ((ans[i] & (1 << j)))
WriteAdvice(1);
else
WriteAdvice(0);
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
void Assist(unsigned char *A, int N, int K, int R)
{
int d[MAXN] = {};
int l = 0;
while ((1 << l) < K)
++l;
++l;
for (int i = 0; i < K; ++i)
d[i] = i;
set<int> s;
for (int i = 0; i < K; ++i)
s.insert(i);
int j = 0;
for (int i = 0; i < N; ++i)
{
int x = GetRequest();
if (s.find(x) != s.end())
continue;
int ans = 0;
for (int ii = 0; ii < l; ++ii, ++j)
{
if (A[j])
ans += (1 << ii);
}
PutBack(d[ans]);
s.erase(d[ans]);
d[ans] = x;
s.insert(d[ans]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3840 KB |
Output is correct |
2 |
Incorrect |
1 ms |
3840 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
4864 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
276 ms |
13560 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4096 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
353 ms |
15856 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
345 ms |
16112 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
336 ms |
16112 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
350 ms |
16112 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
337 ms |
16112 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
337 ms |
15856 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
343 ms |
16112 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
339 ms |
16112 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
408 ms |
16112 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
363 ms |
17648 KB |
Output is partially correct - 1192128 bits used |