#include "advisor.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
vector<int> nxt(N, INT_MAX);
vector<int> val(N);
for (int i = N - 1; i >= 0; --i) {
int a = C[i];
val[i] = nxt[a];
nxt[a] = i;
}
vector<bool> init(K);
vector<bool> rem(N);
priority_queue<ii> que;
R(K) {
que.push({nxt[i], i});
}
vector<bool> has(N);
vector<int> last(N, -1);
R(K) {
has[i] = true;
}
R(N) {
int a = C[i];
if (!has[a]) {
has[a] = true;
int b = que.top().second;
que.pop();
if (last[b] == -1) init[b] = true;
else rem[last[b]] = true;
has[b] = false;
}
last[a] = i;
que.push({val[i], a});
}
R(K) {
if (init[i]) WriteAdvice(1);
else WriteAdvice(0);
}
R(N) {
if (rem[i]) WriteAdvice(1);
else WriteAdvice(0);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
queue<int> rem;
set<int> val;
R(K) {
cerr << "A " << (int)(A[i]) << endl;
}
cerr << "N\n";
R(N) {
cerr << "A " << (int)(A[K + i]) << endl;
}
R(K) {
val.insert(i);
if (A[i]) rem.push(i);
}
R(N) {
int a = GetRequest();
if (!val.count(a)) {
val.insert(a);
int b = rem.front();
PutBack(b);
val.erase(b);
rem.pop();
}
if (A[K + i]) rem.push(a);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
508 KB |
Output is correct |
2 |
Correct |
2 ms |
516 KB |
Output is correct |
3 |
Correct |
9 ms |
772 KB |
Output is correct |
4 |
Correct |
13 ms |
636 KB |
Output is correct |
5 |
Correct |
19 ms |
760 KB |
Output is correct |
6 |
Correct |
20 ms |
820 KB |
Output is correct |
7 |
Correct |
23 ms |
940 KB |
Output is correct |
8 |
Correct |
30 ms |
956 KB |
Output is correct |
9 |
Correct |
24 ms |
956 KB |
Output is correct |
10 |
Correct |
28 ms |
980 KB |
Output is correct |
11 |
Correct |
26 ms |
956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
1100 KB |
Output is correct |
2 |
Correct |
217 ms |
3364 KB |
Output is correct |
3 |
Correct |
560 ms |
8132 KB |
Output is correct |
4 |
Correct |
397 ms |
5152 KB |
Output is correct |
5 |
Correct |
410 ms |
5448 KB |
Output is correct |
6 |
Correct |
438 ms |
6012 KB |
Output is correct |
7 |
Correct |
504 ms |
7268 KB |
Output is correct |
8 |
Correct |
441 ms |
6308 KB |
Output is correct |
9 |
Correct |
408 ms |
5060 KB |
Output is correct |
10 |
Correct |
570 ms |
7792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
408 ms |
5032 KB |
Output is correct |
2 |
Correct |
533 ms |
7736 KB |
Output is correct |
3 |
Correct |
518 ms |
7576 KB |
Output is correct |
4 |
Correct |
537 ms |
7640 KB |
Output is correct |
5 |
Correct |
486 ms |
7264 KB |
Output is correct |
6 |
Correct |
562 ms |
7636 KB |
Output is correct |
7 |
Correct |
517 ms |
7508 KB |
Output is correct |
8 |
Correct |
536 ms |
7044 KB |
Output is correct |
9 |
Correct |
530 ms |
7684 KB |
Output is correct |
10 |
Correct |
539 ms |
7540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
764 KB |
Output is correct |
2 |
Correct |
25 ms |
956 KB |
Output is correct |
3 |
Correct |
24 ms |
748 KB |
Output is correct |
4 |
Correct |
23 ms |
820 KB |
Output is correct |
5 |
Correct |
26 ms |
796 KB |
Output is correct |
6 |
Correct |
23 ms |
948 KB |
Output is correct |
7 |
Correct |
25 ms |
956 KB |
Output is correct |
8 |
Correct |
25 ms |
952 KB |
Output is correct |
9 |
Correct |
25 ms |
948 KB |
Output is correct |
10 |
Correct |
36 ms |
1048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
504 ms |
6208 KB |
Output is correct - 120000 bits used |
2 |
Correct |
520 ms |
6248 KB |
Output is correct - 122000 bits used |
3 |
Correct |
532 ms |
6552 KB |
Output is correct - 125000 bits used |
4 |
Correct |
529 ms |
6476 KB |
Output is correct - 125000 bits used |
5 |
Correct |
525 ms |
6484 KB |
Output is correct - 125000 bits used |
6 |
Correct |
511 ms |
6304 KB |
Output is correct - 125000 bits used |
7 |
Correct |
511 ms |
6428 KB |
Output is correct - 124828 bits used |
8 |
Correct |
545 ms |
6480 KB |
Output is correct - 124910 bits used |
9 |
Correct |
521 ms |
6456 KB |
Output is correct - 125000 bits used |
10 |
Correct |
514 ms |
6004 KB |
Output is correct - 125000 bits used |