#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 = 1; i <= K; i++) q.push(MP(fp[i - 1].back(), i)), col[i - 1] = i, b[i] = i - 1, c[i] = i - 1;
i1 = K;
for (int i = 0; i < N; i++)
{
fp[C[i]].pop_back();
if (col[C[i]])
{
q.push(MP(fp[C[i]].back(), col[C[i]]));
c[col[C[i]]] = i1 + i;
continue;
}
int p = q.top().sc;
q.pop();
col[b[p]] = 0, col[C[i]] = p;
ans[c[p]] = 1, c[p] = i1 + i;
b[p] = C[i];
q.push(MP(fp[C[i]].back(), col[C[i]]));
}
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 = 1; i <= K; i++)
{
col1[i - 1] = i, b1[i] = i - 1;
if (A[i - 1]) fp1.ad(i);
}
ii = K;
for (int i = 0; i < N; i++)
{
int a = GetRequest();
if (col1[a])
{
if (A[ii + i]) fp1.ad(col1[a]);
continue;
}
int p = fp1.back();
fp1.pop_back();
PutBack(b1[p]);
col1[b1[p]] = 0, col1[a] = p;
b1[p] = a;
if (A[ii + i]) fp1.ad(col1[a]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
24104 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
24952 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
75 ms |
29848 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
24484 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
119 ms |
31552 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
102 ms |
31600 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
93 ms |
31560 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
88 ms |
31524 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
88 ms |
31584 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
91 ms |
31520 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
98 ms |
31892 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
89 ms |
31568 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
89 ms |
31500 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
94 ms |
31076 KB |
Error - Putting back a color that is not on the scaffold |