#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
string dectobin(int x, int mx) {
string res = "";
for (int i = mx; i >= 0; i--) {
if ((1 << i) & x) res += '1';
else res += '0';
}
return res;
}
void ComputeAdvice(int *C, int N, int K, int M) {
int mx = log2(N-1);
for (int i = 0; i < N; i++) {
string tmp = dectobin(C[i],mx);
for (auto j : tmp) WriteAdvice(j-'0');
}
}
#include <bits/stdc++.h>
#define f first
#define s second
#include "assistant.h"
using namespace std;
int C[100005];
deque<int> pos[100005];
void Assist(unsigned char *A, int N, int K, int R) {
int lg = log2(N-1)+1;
for (int i = 0; i < R; i++) {
C[i/lg] += (1 << (lg - i % lg - 1)) * A[i];
}
for (int i = 0; i < N; i++) pos[C[i]].push_back(i);
for (int i = 0; i < N; i++) pos[i].push_back(1e9);
set<pair<int,int>> cur;
for (int i = 0; i < K; i++) cur.insert({pos[i][0],i});
for (int i = 0; i < N; i++) {
GetRequest();
if (cur.find({pos[C[i]][0],C[i]}) != cur.end()) {
cur.erase({pos[C[i]][0],C[i]});
pos[C[i]].pop_front();
cur.insert({pos[C[i]][0],C[i]});
} else {
pos[C[i]].pop_front();
PutBack((*cur.rbegin()).s);
cur.erase(*cur.rbegin());
cur.insert({pos[C[i]][0],C[i]});
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
67832 KB |
Output is correct |
2 |
Correct |
41 ms |
67908 KB |
Output is correct |
3 |
Correct |
42 ms |
68224 KB |
Output is correct |
4 |
Correct |
49 ms |
68216 KB |
Output is correct |
5 |
Correct |
57 ms |
68400 KB |
Output is correct |
6 |
Correct |
67 ms |
68344 KB |
Output is correct |
7 |
Correct |
52 ms |
68320 KB |
Output is correct |
8 |
Correct |
54 ms |
68312 KB |
Output is correct |
9 |
Correct |
57 ms |
68448 KB |
Output is correct |
10 |
Correct |
58 ms |
68388 KB |
Output is correct |
11 |
Correct |
59 ms |
68404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
69112 KB |
Output is correct |
2 |
Correct |
229 ms |
74740 KB |
Output is correct |
3 |
Correct |
458 ms |
83204 KB |
Output is correct |
4 |
Correct |
412 ms |
81460 KB |
Output is correct |
5 |
Correct |
402 ms |
81808 KB |
Output is correct |
6 |
Correct |
411 ms |
81788 KB |
Output is correct |
7 |
Correct |
424 ms |
82524 KB |
Output is correct |
8 |
Correct |
376 ms |
80596 KB |
Output is correct |
9 |
Correct |
389 ms |
81320 KB |
Output is correct |
10 |
Correct |
434 ms |
82988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
353 ms |
79840 KB |
Output is correct |
2 |
Incorrect |
67 ms |
70748 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
67900 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
438 ms |
82608 KB |
Output is partially correct - 1700000 bits used |
2 |
Correct |
473 ms |
82680 KB |
Output is partially correct - 1700000 bits used |
3 |
Correct |
445 ms |
82748 KB |
Output is partially correct - 1700000 bits used |
4 |
Correct |
421 ms |
82868 KB |
Output is partially correct - 1700000 bits used |
5 |
Correct |
442 ms |
82772 KB |
Output is partially correct - 1700000 bits used |
6 |
Correct |
440 ms |
82812 KB |
Output is partially correct - 1700000 bits used |
7 |
Correct |
462 ms |
82740 KB |
Output is partially correct - 1697263 bits used |
8 |
Correct |
431 ms |
82920 KB |
Output is partially correct - 1700000 bits used |
9 |
Correct |
436 ms |
82832 KB |
Output is partially correct - 1700000 bits used |
10 |
Correct |
434 ms |
82820 KB |
Output is partially correct - 1700000 bits used |