#include "Anna.h"
#include <bits/stdc++.h>
#define ll long long
#define re(a, b, c, d) for (auto a = b; a <= c; a += d)
#define de(a, b, c, d) for (auto a = b; a >= c; a -= d)
#define ms (a); memset (a, 0, sizeof a);
#define imax INT_MAX
#define imin INT_MIN
#define wh(a) while (a --)
#define PII pair <int, int>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
template <typename T> bool chkmin (T &a, T b) {
return (b < a) ? a = b, 1 : 0;
}
template <typename T> bool chkmax (T &a, T b) {
return (b > a) ? a = b, 1 : 0;
}
using namespace std;
ll fib[64];
void init() {
fib[0] = 1, fib[1] = 2;
re (i, 2, 63, 1) fib[i] = fib[i - 1] + fib[i - 2];
}
ll upd (const vector<int> &a, int l, int r) {
if (l > r) return 0;
if (l == r) return a[l];
if (a[l]) return fib[r - l] + upd (a, l + 2, r);
else return upd (a, l + 1, r);
}
void Anna (int n, vector<char> s) {
init ();
vector<int> res;
re (i, 0, n - 1, 1) if (s[i] == 'X') {
res.pb (1);
res.pb (0);
re (j, i + 1, n - 1, 1) res.pb (s[j] == 'Z' && (j == n - 1 || s[j + 1] != 'Z'));
break;
} else res.pb (0);
if ((int)res.size() == n) return;
while (res.size() % 63) res.pb (0);
for (int i = 0; i < (int)res.size(); i += 63) {
ll cur = upd (res, i, i + 62);
de (j, 43, 0, 1) Send (cur >> j & 1);
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
#define ll long long
#define re(a, b, c, d) for (auto a = b; a <= c; a += d)
#define de(a, b, c, d) for (auto a = b; a >= c; a -= d)
#define ms (a); memset (a, 0, sizeof a);
#define imax INT_MAX
#define imin INT_MIN
#define wh(a) while (a --)
#define PII pair <int, int>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
template <typename T> bool chkmin (T &a, T b) {
return (b < a) ? a = b, 1 : 0;
}
template <typename T> bool chkmax (T &a, T b) {
return (b > a) ? a = b, 1 : 0;
}
using namespace std;
ll fib[64];
void init() {
fib[0] = 1, fib[1] = 2;
re (i, 2, 63, 1) fib[i] = fib[i - 1] + fib[i - 2];
}
void qry (vector<int> &a, ll cur, int l) {
if (!l) return;
if (l == 1) a.pb (cur);
else if (cur < fib[l - 1]) a.pb (0), qry (a, cur, l - 1);
else a.pb (1), a.pb (0), qry (a, cur - fib[l - 1], l - 2);
}
void Bruno (int n, int l, vector<int> a) {
if (a.empty()) {
re (i, 0, n - 1, 1) Remove (i);
return;
}
init();
vector<int> res;
re (i, 0, l - 1, 44) {
ll cur = 0;
re (j, 0, 43, 1) if (a[i + j]) cur |= (1ll << (43 - j));
qry (res, cur, 63);
}
while ((int)res.size() > n + 1) res.pop_back();
re (i, 0, n - 1, 1) if (res[i]) {
res.erase (res.begin() + i + 1);
de (j, i - 1, 0, 1) Remove (j);
int lst = i;
re (j, i + 1, n - 1, 1) if (res[j]) {
de (k, j - 1, lst + 1, 1) Remove (k);
Remove (j);
lst = j;
}
re (j, lst + 1, n - 1, 1) Remove (j);
Remove (i);
break;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
792 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
0 ms |
796 KB |
Output is correct |
4 |
Correct |
0 ms |
796 KB |
Output is correct |
5 |
Correct |
0 ms |
784 KB |
Output is correct |
6 |
Correct |
0 ms |
784 KB |
Output is correct |
7 |
Correct |
0 ms |
796 KB |
Output is correct |
8 |
Correct |
0 ms |
1036 KB |
Output is correct |
9 |
Correct |
0 ms |
796 KB |
Output is correct |
10 |
Correct |
0 ms |
784 KB |
Output is correct |
11 |
Correct |
0 ms |
784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
8760 KB |
Output is correct |
2 |
Correct |
32 ms |
8556 KB |
Output is correct |
3 |
Correct |
31 ms |
8644 KB |
Output is correct |
4 |
Correct |
38 ms |
8564 KB |
Output is correct |
5 |
Correct |
33 ms |
8540 KB |
Output is correct |
6 |
Correct |
32 ms |
8532 KB |
Output is correct |
7 |
Correct |
33 ms |
8920 KB |
Output is correct |
8 |
Correct |
32 ms |
8544 KB |
Output is correct |
9 |
Correct |
33 ms |
8544 KB |
Output is correct |
10 |
Correct |
32 ms |
8772 KB |
Output is correct |
11 |
Correct |
32 ms |
8544 KB |
Output is correct |
12 |
Correct |
32 ms |
8548 KB |
Output is correct |
13 |
Correct |
40 ms |
8528 KB |
Output is correct |
14 |
Correct |
39 ms |
8484 KB |
Output is correct |
15 |
Correct |
35 ms |
8468 KB |
Output is correct |
16 |
Correct |
35 ms |
8612 KB |
Output is correct |
17 |
Correct |
39 ms |
8536 KB |
Output is correct |
18 |
Correct |
35 ms |
7548 KB |
Output is correct |
19 |
Correct |
31 ms |
7540 KB |
Output is correct |
20 |
Correct |
32 ms |
8812 KB |
Output is correct |
21 |
Correct |
32 ms |
8716 KB |
Output is correct |
22 |
Correct |
39 ms |
8824 KB |
Output is correct |
23 |
Correct |
33 ms |
8536 KB |
Output is correct |
24 |
Correct |
39 ms |
8396 KB |
Output is correct |
25 |
Correct |
31 ms |
7404 KB |
Output is correct |
26 |
Correct |
44 ms |
8776 KB |
Output is correct |
27 |
Correct |
37 ms |
8536 KB |
Output is correct |
28 |
Correct |
39 ms |
8872 KB |
Output is correct |
29 |
Correct |
31 ms |
7544 KB |
Output is correct |
30 |
Correct |
38 ms |
8460 KB |
Output is correct |
31 |
Correct |
32 ms |
7600 KB |
Output is correct |
32 |
Correct |
32 ms |
8564 KB |
Output is correct |
33 |
Correct |
32 ms |
8800 KB |
Output is correct |