#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
int post[1 << 18], I[1 << 18]; vector<int> Z[1 << 18];
bool used[1 << 18];
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i = 0; i < N; i++) Z[C[i]].push_back(i);
for (int i = 0; i < N; i++) post[i] = (1 << 30);
for (int i = 0; i < K; i++) {
for (int j = (int)Z[i].size() - 2; j >= 0; j--) post[Z[i][j]] = Z[i][j + 1];
}
priority_queue<pair<int, int>, vector<pair<int, int>>, less<pair<int, int>>> que;
for (int i = 0; i < K; i++) {
used[i] = true; I[i] = i;
if (Z[i].size() >= 1) que.push(make_pair(Z[i][0], i));
else que.push(make_pair((1 << 30), i));
}
vector<int> L;
for (int i = 0; i < N; i++) {
if (used[C[i]] == false) {
pair<int, int> G = que.top(); que.pop();
used[G.second] = false; I[C[i]] = I[G.second]; L.push_back(I[C[i]]);
}
que.push(make_pair(post[i], C[i])); used[C[i]] = true;
}
int sz = 0, size_ = 1;
while (size_ < K) { size_ *= 2; sz++; }
for (int i = 0; i < L.size(); i++) {
for (int j = 0; j < sz; j++) WriteAdvice((L[i] / (1 << j)) % 2);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
int LL[1 << 18], DAI[1 << 18]; bool used2[1 << 18];
void Assist(unsigned char *A, int N, int K, int R) {
int sz = 0, size_ = 1;
while (size_ < K) { size_ *= 2; sz++; }
for (int i = 0; i < R / sz; i++) {
for (int j = 0; j < sz; j++) { LL[i] += A[i * sz + j] * (1 << j); }
}
for (int i = 0; i < K; i++) { used2[i] = true; DAI[i] = i; }
int cnt = 0;
for (int i = 0; i < N; i++) {
int G = GetRequest();
if (used2[G] == false) {
PutBack(LL[cnt]); cnt++;
used2[G] = true; used2[DAI[LL[cnt]]] = false; DAI[LL[cnt]] = G;
}
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:34:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < L.size(); i++) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
13056 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
14592 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
269 ms |
25768 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
13312 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
310 ms |
29320 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
458 ms |
29136 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
299 ms |
28536 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
367 ms |
28592 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
328 ms |
28536 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
424 ms |
28672 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
322 ms |
28792 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
341 ms |
28792 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
314 ms |
28984 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
356 ms |
31168 KB |
Error - Putting back a color that is not on the scaffold |