#include "Anna.h"
#include <cassert>
#include <vector>
using namespace std;
typedef vector<char> str;
namespace A {
const int N = 100001, K = 63, L = 44, M = 70000;
long long ff[K + 1];
void init() {
ff[0] = 1, ff[1] = 2;
for (int i = 2; i <= K; i++)
ff[i] = ff[i - 1] + ff[i - 2];
assert(1LL << L >= ff[K] && (N + K - 1) / K * L <= M);
}
}
void encode(str aa, int n) {
for (int i = 0; i < n; i += A::K) {
long long x = 0;
for (int j = 0; j < A::K && i + j < n; j++)
if (aa[i + j] == 1)
x += A::ff[j];
for (int l = 0; l < A::L; l++)
Send(x >> l & 1);
}
}
void Anna(int n, str cc) {
A::init();
int ix = 0;
while (ix < n && cc[ix] != 'X')
ix++;
int iz = n - 1;
while (iz >= 0 && cc[iz] != 'Z')
iz--;
str aa(n + 1, 0);
if (ix < iz) {
aa[ix] = 1;
for (int i = ix + 1; i < iz; i++)
if (cc[i] == 'Z' && cc[i + 1] == 'Y')
aa[i + 1] = 1;
aa[iz + 1] = 1;
}
encode(aa, n + 1);
}
#include "Bruno.h"
#include <cassert>
#include <vector>
using namespace std;
typedef vector<int> vi;
namespace B {
const int N = 100001, K = 63, L = 44, M = 70000;
long long ff[K + 1];
void init() {
ff[0] = 1, ff[1] = 2;
for (int i = 2; i <= K; i++)
ff[i] = ff[i - 1] + ff[i - 2];
assert(1LL << L >= ff[K] && (N + K - 1) / K * L <= M);
}
}
vi decode(vi aa, int n) {
vi bb(n / B::L * B::K, 0);
for (int i = 0; i < n; i += B::L) {
long long x = 0;
for (int l = 0; l < B::L; l++)
if (aa[i + l] == 1)
x |= 1LL << l;
int j = B::K - 1;
while (j >= 0)
if (x >= B::ff[j])
x -= B::ff[j], bb[i / B::L * B::K + j] = 1, j -= 2;
else
j--;
}
return bb;
}
void Bruno(int n, int l, vi aa) {
B::init();
aa = decode(aa, l);
int ix = 0;
while (ix < n && aa[ix] == 0)
ix++;
if (ix == n)
for (int i = 0; i < n; i++)
Remove(i);
else {
for (int i = ix + 1; i < n; i++)
aa[i] = aa[i + 1];
int iz = n - 1;
while (iz >= 0 && aa[iz] == 0)
iz--;
for (int h = ix, i = ix + 1; i <= iz; i++)
if (aa[i] == 1) {
for (int j = i - 1; j > h; j--)
Remove(j);
h = i + 1;
}
for (int i = ix + 1; i <= iz; i++)
if (aa[i] == 1) {
Remove(i);
if (i < iz)
Remove(i + 1);
}
for (int i = ix; i >= 0; i--)
Remove(i);
for (int i = iz + 1; i < n; i++)
Remove(i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
508 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
0 ms |
520 KB |
Output is correct |
4 |
Correct |
1 ms |
508 KB |
Output is correct |
5 |
Correct |
0 ms |
516 KB |
Output is correct |
6 |
Correct |
0 ms |
516 KB |
Output is correct |
7 |
Correct |
0 ms |
508 KB |
Output is correct |
8 |
Correct |
0 ms |
508 KB |
Output is correct |
9 |
Correct |
0 ms |
508 KB |
Output is correct |
10 |
Correct |
0 ms |
508 KB |
Output is correct |
11 |
Correct |
0 ms |
516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
7556 KB |
Output is correct |
2 |
Correct |
57 ms |
7604 KB |
Output is correct |
3 |
Correct |
55 ms |
7556 KB |
Output is correct |
4 |
Correct |
57 ms |
7688 KB |
Output is correct |
5 |
Correct |
53 ms |
7568 KB |
Output is correct |
6 |
Correct |
51 ms |
7528 KB |
Output is correct |
7 |
Correct |
54 ms |
7508 KB |
Output is correct |
8 |
Correct |
56 ms |
7568 KB |
Output is correct |
9 |
Correct |
53 ms |
7504 KB |
Output is correct |
10 |
Correct |
63 ms |
7548 KB |
Output is correct |
11 |
Correct |
51 ms |
7604 KB |
Output is correct |
12 |
Correct |
53 ms |
7588 KB |
Output is correct |
13 |
Correct |
57 ms |
7544 KB |
Output is correct |
14 |
Correct |
61 ms |
7556 KB |
Output is correct |
15 |
Correct |
65 ms |
7576 KB |
Output is correct |
16 |
Correct |
53 ms |
7628 KB |
Output is correct |
17 |
Correct |
56 ms |
7560 KB |
Output is correct |
18 |
Correct |
66 ms |
7556 KB |
Output is correct |
19 |
Correct |
60 ms |
7604 KB |
Output is correct |
20 |
Correct |
51 ms |
7556 KB |
Output is correct |
21 |
Correct |
47 ms |
7524 KB |
Output is correct |
22 |
Correct |
54 ms |
7580 KB |
Output is correct |
23 |
Correct |
47 ms |
7616 KB |
Output is correct |
24 |
Correct |
48 ms |
7556 KB |
Output is correct |
25 |
Correct |
60 ms |
7624 KB |
Output is correct |
26 |
Correct |
53 ms |
7552 KB |
Output is correct |
27 |
Correct |
55 ms |
7680 KB |
Output is correct |
28 |
Correct |
59 ms |
7552 KB |
Output is correct |
29 |
Correct |
53 ms |
7604 KB |
Output is correct |
30 |
Correct |
53 ms |
7496 KB |
Output is correct |
31 |
Correct |
55 ms |
7568 KB |
Output is correct |
32 |
Correct |
55 ms |
7556 KB |
Output is correct |
33 |
Correct |
49 ms |
7576 KB |
Output is correct |