#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int n2 = 0;
for (n2 = 0; (1 << (n2 + 1)) < N; ++ n2) {
}
for (int i = 0; i < N; ++ i) {
for (int j = 0; j <= n2; ++ j) {
WriteAdvice(C[i] % 2);
C[i] /= 2;
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5;
bool viz[nmax + 1];
int f[nmax + 1];
int nxt[nmax + 1];
void Assist(unsigned char *A, int N, int K, int R) {
vector<int> c;
int n2 = 0;
for (n2 = 0; (1 << (n2 + 1)) < N; ++ n2) {
}
for (int i = 0; i < R; i += n2 + 1) {
int x = 0;
int p2 = 1;
for (int j = i; j <= i + n2; ++ j) {
x = x + p2 * A[j];
p2 *= 2;
}
c.push_back(x);
}
for (int i = 0; i < N; ++ i)
f[i] = (1 << 30);
for (int i = N - 1; i > 0; -- i) {
nxt[i] = -f[c[i]];
f[c[i]] = i;
}
set<pair<int, int>> s;
for (int i = 0; i < K; ++ i) {
viz[i] = 1;
s.insert({-f[i], i});
}
int i;
for (i = 0; i < N; i++) {
int req = GetRequest();
if (viz[req] == 1) {
s.erase({-i, req});
} else {
int x = s.begin() -> second;
PutBack(x);
viz[x] = 0;
s.erase(s.begin());
}
viz[req] = 1;
s.insert({nxt[i], req});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
772 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
2140 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
328 ms |
13420 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
788 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
402 ms |
16048 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
386 ms |
16080 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
408 ms |
16404 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
370 ms |
16264 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
545 ms |
16536 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
421 ms |
16384 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
394 ms |
16372 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
419 ms |
16252 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
395 ms |
16352 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
344 ms |
15856 KB |
Output isn't correct - not an optimal way |