#include <bits/stdc++.h>
#include "advisor.h"
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 1e5+5;
static queue<int> pos[N];
static bool inq[N];
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i = 0; i < N; ++i) pos[C[i]].emplace(i);
for(int i = 0; i < N; ++i) pos[i].emplace(N);
set<pii, greater<pii> > Q;
for(int i = 0; i < K; ++i) Q.emplace(pos[i].front(), i), inq[i] = true;
for(int i = 0; i < N; ++i) {
if(inq[C[i]]) {
Q.erase(pii(pos[C[i]].front(), i));
} else {
int v = Q.begin()->y; Q.erase(Q.begin());
inq[v] = false, inq[C[i]] = true;
for(int i = 0; i < 17; ++i) WriteAdvice(v >> i & 1);
}
pos[C[i]].pop();
Q.emplace(pos[C[i]].front(), C[i]);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
set<int> S;
for(int i = 0; i < K; ++i) S.emplace(i);
int ptr = 0;
for(int i = 0; i < N; ++i) {
int v;
if(S.count(v = GetRequest())) continue;
int val = 0;
for(int i = 0; i < 17; ++i) if(A[ptr++]) val |= (1 << i);
PutBack(val);
S.erase(val);
S.emplace(v);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
135160 KB |
Output is correct |
2 |
Correct |
63 ms |
135152 KB |
Output is correct |
3 |
Correct |
63 ms |
135408 KB |
Output is correct |
4 |
Correct |
72 ms |
135664 KB |
Output is correct |
5 |
Incorrect |
67 ms |
135416 KB |
Error - advice is too long |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
136688 KB |
Output is correct |
2 |
Correct |
184 ms |
142192 KB |
Output is correct |
3 |
Correct |
410 ms |
151848 KB |
Output is correct |
4 |
Correct |
429 ms |
148464 KB |
Output is correct |
5 |
Correct |
425 ms |
148464 KB |
Output is correct |
6 |
Correct |
398 ms |
148896 KB |
Output is correct |
7 |
Correct |
386 ms |
150000 KB |
Output is correct |
8 |
Correct |
379 ms |
148720 KB |
Output is correct |
9 |
Correct |
395 ms |
148208 KB |
Output is correct |
10 |
Correct |
397 ms |
151024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
323 ms |
146792 KB |
Output is correct |
2 |
Correct |
393 ms |
150480 KB |
Output is correct |
3 |
Correct |
645 ms |
150768 KB |
Output is correct |
4 |
Correct |
368 ms |
150512 KB |
Output is correct |
5 |
Correct |
325 ms |
149744 KB |
Output is correct |
6 |
Correct |
397 ms |
150768 KB |
Output is correct |
7 |
Correct |
368 ms |
150512 KB |
Output is correct |
8 |
Correct |
444 ms |
151080 KB |
Output is correct |
9 |
Correct |
290 ms |
150984 KB |
Output is correct |
10 |
Correct |
377 ms |
150584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
67 ms |
135408 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
397 ms |
149128 KB |
Output is partially correct - 875347 bits used |
2 |
Partially correct |
388 ms |
149232 KB |
Output is partially correct - 841041 bits used |
3 |
Partially correct |
383 ms |
149560 KB |
Output is partially correct - 807466 bits used |
4 |
Partially correct |
371 ms |
149488 KB |
Output is partially correct - 806939 bits used |
5 |
Partially correct |
377 ms |
149488 KB |
Output is partially correct - 805358 bits used |
6 |
Partially correct |
376 ms |
149744 KB |
Output is partially correct - 807109 bits used |
7 |
Partially correct |
403 ms |
149304 KB |
Output is partially correct - 805902 bits used |
8 |
Partially correct |
384 ms |
149536 KB |
Output is partially correct - 808452 bits used |
9 |
Partially correct |
376 ms |
149488 KB |
Output is partially correct - 807874 bits used |
10 |
Partially correct |
435 ms |
149784 KB |
Output is partially correct - 1266636 bits used |