#include "advisor.h"
//#include "grader.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 hl[MAXN] = {};
int u[MAXN] = {};
int d[MAXN] = {};
int ans[MAXN] = {};
bool ps[MAXN] = {};
bool p[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 < N; ++i)
u[i] = -1;
for (int i = 0; i < N; ++i)
{
hl[i] = u[C[i]];
u[C[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())
{
if (hl[i] == -1)
ps[C[i]] = true;
else
{
p[hl[i]] = true;
}
ss.erase(m_p(i, C[i]));
ss.insert(m_p(h[i], C[i]));
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];
}
for (int i = 0; i < K; ++i)
{
WriteAdvice(ps[i]);
}
for (int i = 0; i < N; ++i)
{
WriteAdvice(p[i]);
}
return;
int l = 0;
while ((1 << l) < K)
++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] = {};
bool p[MAXN] = {};
int l = 0;
while ((1 << l) < K)
++l;
int j = 0;
for (int i = 0; i < K; ++i)
{
d[i] = i;
p[i] = A[j++];
}
set<int> s;
for (int i = 0; i < K; ++i)
s.insert(i);
for (int i = 0; i < N; ++i)
{
int x = GetRequest();
if (s.find(x) != s.end())
{
for (int u = 0; u < K; ++u)
{
if (d[u] == x)
{
p[u] = A[j++];
break;
}
}
continue;
}
for (int u = 0; u < K; ++u)
{
if (!p[u])
{
s.erase(d[u]);
s.insert(x);
PutBack(d[u]);
d[u] = x;
p[u] = A[j++];
break;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3328 KB |
Output is correct |
2 |
Correct |
2 ms |
3328 KB |
Output is correct |
3 |
Correct |
3 ms |
3584 KB |
Output is correct |
4 |
Correct |
5 ms |
3584 KB |
Output is correct |
5 |
Correct |
6 ms |
3584 KB |
Output is correct |
6 |
Correct |
8 ms |
3584 KB |
Output is correct |
7 |
Correct |
8 ms |
3584 KB |
Output is correct |
8 |
Correct |
8 ms |
3840 KB |
Output is correct |
9 |
Correct |
11 ms |
3584 KB |
Output is correct |
10 |
Correct |
12 ms |
3840 KB |
Output is correct |
11 |
Correct |
11 ms |
3840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
4096 KB |
Output is correct |
2 |
Correct |
129 ms |
5880 KB |
Output is correct |
3 |
Correct |
808 ms |
13808 KB |
Output is correct |
4 |
Correct |
106 ms |
7152 KB |
Output is correct |
5 |
Correct |
142 ms |
7152 KB |
Output is correct |
6 |
Correct |
328 ms |
8176 KB |
Output is correct |
7 |
Correct |
688 ms |
10736 KB |
Output is correct |
8 |
Correct |
305 ms |
11248 KB |
Output is correct |
9 |
Correct |
94 ms |
7152 KB |
Output is correct |
10 |
Correct |
814 ms |
12808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
511 ms |
10368 KB |
Output is correct |
2 |
Correct |
757 ms |
11760 KB |
Output is correct |
3 |
Correct |
795 ms |
12016 KB |
Output is correct |
4 |
Correct |
828 ms |
12016 KB |
Output is correct |
5 |
Correct |
749 ms |
10992 KB |
Output is correct |
6 |
Correct |
791 ms |
12016 KB |
Output is correct |
7 |
Correct |
822 ms |
12016 KB |
Output is correct |
8 |
Correct |
352 ms |
12016 KB |
Output is correct |
9 |
Correct |
936 ms |
12016 KB |
Output is correct |
10 |
Correct |
799 ms |
12016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3840 KB |
Output is correct |
2 |
Correct |
7 ms |
3840 KB |
Output is correct |
3 |
Correct |
7 ms |
3584 KB |
Output is correct |
4 |
Correct |
6 ms |
3584 KB |
Output is correct |
5 |
Correct |
8 ms |
3584 KB |
Output is correct |
6 |
Correct |
8 ms |
3584 KB |
Output is correct |
7 |
Correct |
10 ms |
3584 KB |
Output is correct |
8 |
Correct |
10 ms |
3840 KB |
Output is correct |
9 |
Correct |
10 ms |
3840 KB |
Output is correct |
10 |
Correct |
14 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
732 ms |
10992 KB |
Output is correct - 120000 bits used |
2 |
Correct |
769 ms |
11248 KB |
Output is correct - 122000 bits used |
3 |
Correct |
796 ms |
12016 KB |
Output is correct - 125000 bits used |
4 |
Correct |
786 ms |
12016 KB |
Output is correct - 125000 bits used |
5 |
Correct |
797 ms |
12016 KB |
Output is correct - 125000 bits used |
6 |
Correct |
776 ms |
12272 KB |
Output is correct - 125000 bits used |
7 |
Correct |
776 ms |
12016 KB |
Output is correct - 124828 bits used |
8 |
Correct |
788 ms |
12016 KB |
Output is correct - 124910 bits used |
9 |
Correct |
804 ms |
12016 KB |
Output is correct - 125000 bits used |
10 |
Correct |
390 ms |
12016 KB |
Output is correct - 125000 bits used |