#include "advisor.h"
#include <iostream>
#include <vector>
#include <queue>
#define MP make_pair
#define fr first
#define sc second
#define ad push_back
using namespace std;
const int N = 1e6 + 30;
int i1 = 0;
int col[N], b[N], c[N];
int ans[N];
vector<int> fp[N];
void ComputeAdvice(int *C, int N, int K, int M)
{
for (int i = 0; i < N; i++) fp[i].ad(N);
for (int i = N - 1; i >= 0; i--) fp[C[i]].ad(i);
priority_queue <pair<int, int> > q;
for (int i = 0; i < K; i++) q.push(MP(fp[i].back(), i)), col[i] = 1, b[i] = i;
for (int i = 0; i < N; i += K)
{
for (int j = 0; j < min(N, i + K) - i; j++) c[j] = i1 + j;
for (int j = i; j < min(N, i + K); j++)
{
if (col[C[j]]) continue;
int p = q.top().sc;
q.pop();
ans[c[p]] = 1;
col[C[j]] = 1, col[b[p]] = 0;
b[p] = C[j], c[p] = i1 + K + j - i;
fp[C[j]].pop_back();
q.push(MP(fp[C[j]].back(), p));
}
i1 += (min(N, i + K) - i) * 2;
}
for (int i = 0; i < i1; i++) WriteAdvice(ans[i]);
}
#include "assistant.h"
#include <iostream>
#include <vector>
#include <queue>
#define MP make_pair
#define fr first
#define sc second
#define ad push_back
using namespace std;
const int N1 = 1e6 + 30;
int ii;
int col1[N1], b1[N1];
vector <int> fp1;
void Assist(unsigned char *A, int N, int K, int R)
{
for (int i = 0; i < K; i++) col1[i] = 1, b1[i] = i;
for (int i = 0; i < N; i += K)
{
for (int j = 0; j < min(N, i + K) - i; j++) if (A[ii + j] == 1) fp1.ad(j);
for (int j = i; j < min(N, i + K); j++)
{
int a = GetRequest();
if (col1[a]) continue;
int p = fp1.back();
fp1.pop_back();
col1[b1[p]] = 0, col1[a] = 1;
PutBack(b1[p]);
b1[p] = a;
if (A[ii + K + j - i] == 1) fp1.ad(p);
}
ii += K * 2;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
24104 KB |
Output is correct |
2 |
Incorrect |
15 ms |
24100 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
25064 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
105 ms |
31700 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
24640 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
140 ms |
33488 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
148 ms |
33560 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
133 ms |
33736 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
140 ms |
33648 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
134 ms |
33584 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
133 ms |
33636 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
129 ms |
33644 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
124 ms |
33620 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
133 ms |
33660 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Correct |
129 ms |
33480 KB |
Output is correct - 200000 bits used |