#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace {
const int MAXN = 1e5;
ll fib[MAXN];
const int LEN_MAX = 50;
const int BIT_MAX = 35;
inline ll encode(vector<int> vec) {
ll ans = 0;
for (int i = 0; i < LEN_MAX; i++)
if (vec[i])
ans += fib[LEN_MAX - i - 1];
return ans;
}
}
void Anna(int N, vector<char> S) {
fib[0] = 1, fib[1] = 2;
for (int i = 2; i <= LEN_MAX; i++)
fib[i] = fib[i - 1] + fib[i - 2];
vector<int> ans = {0};
for (int i = 1; i < N; i++) {
ans.push_back(S[i - 1] == 'Z');
}
int ind = 0;
while (S[ind] != 'X' && ind < N) ind++;
if (ind == N) return;
for (int i = 0; i <= ind; i++) ans[i] = 0;
ans[ind] = 1;
for (int i = N - 2; i >= 0; i--)
if (ans[i] + ans[i + 1] == 2)
ans[i] = 0;
while (int(ans.size()) < MAXN) ans.push_back(0);
vector<int> fans;
for (int i = 0; i < int(ans.size()); i += LEN_MAX) {
vector<int> tmp;
for (int j = 0; j < LEN_MAX; j++)
tmp.push_back(ans[i + j]);
ll x = encode(tmp);
for (int i = 0; i < BIT_MAX; i++)
fans.push_back((x >> i & 1ll));
}
for (int e : fans)
Send(e);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace {
const int MAXN = 1e5;
const int MAX_LEN = 50;
const int MAX_BIT = 35;
ll fib[MAXN];
inline vector<int> decode(ll x) {
vector<int> ans;
for (int i = 0; i < MAX_LEN; i++) {
if (x >= fib[MAX_LEN - i - 1]) {
ans.push_back(1);
x -= fib[MAX_LEN - i - 1];
} else {
ans.push_back(0);
}
}
return ans;
}
} // namespace
void Bruno(int N, int L, std::vector<int> TTA) {
if (!L) {
for (int i = 0; i < N; i++)
Remove(i);
return;
}
fib[0] = 1, fib[1] = 2;
for (int i = 2; i <= MAX_LEN; i++)
fib[i] = fib[i - 1] + fib[i - 2];
vector<int> TA;
for (int i = 0; i < L; i += MAX_BIT) {
ll x = 0;
for (int j = 0; j < MAX_BIT; j++)
if (TTA[i + j])
x |= (1ll << j);
vector<int> tmp = decode(x);
for (int e : tmp)
TA.push_back(e);
}
int ind = 0;
vector<int> A(N);
while (!TA[ind]) ind++;
for (int i = 0; i < ind; i++)
A[i] = 1;
A[N - 1] = 1;
for (int i = ind + 1; i < N; i++)
A[i - 1] = TA[i];
stack<int> st;
bool flag = false;
for (int i = 0; i < N; i++) {
if (A[i]) {
while (st.size() > 1) {
Remove(st.top());
st.pop();
}
Remove(i);
} else st.push(i);
}
while (!st.empty()) {
Remove(st.top());
st.pop();
}
}
Compilation message
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:66:7: warning: unused variable 'flag' [-Wunused-variable]
66 | bool flag = false;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
3428 KB |
Output is correct |
2 |
Correct |
11 ms |
3468 KB |
Output is correct |
3 |
Correct |
11 ms |
3472 KB |
Output is correct |
4 |
Correct |
11 ms |
3424 KB |
Output is correct |
5 |
Correct |
13 ms |
3488 KB |
Output is correct |
6 |
Correct |
11 ms |
3452 KB |
Output is correct |
7 |
Correct |
13 ms |
3488 KB |
Output is correct |
8 |
Correct |
11 ms |
3520 KB |
Output is correct |
9 |
Correct |
11 ms |
3480 KB |
Output is correct |
10 |
Correct |
0 ms |
516 KB |
Output is correct |
11 |
Correct |
0 ms |
524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
9172 KB |
Output is correct |
2 |
Correct |
45 ms |
9096 KB |
Output is correct |
3 |
Correct |
40 ms |
9184 KB |
Output is correct |
4 |
Correct |
39 ms |
9216 KB |
Output is correct |
5 |
Correct |
39 ms |
9116 KB |
Output is correct |
6 |
Correct |
40 ms |
9256 KB |
Output is correct |
7 |
Correct |
39 ms |
9204 KB |
Output is correct |
8 |
Correct |
39 ms |
9292 KB |
Output is correct |
9 |
Correct |
39 ms |
9288 KB |
Output is correct |
10 |
Correct |
39 ms |
9196 KB |
Output is correct |
11 |
Correct |
40 ms |
9216 KB |
Output is correct |
12 |
Correct |
41 ms |
9104 KB |
Output is correct |
13 |
Correct |
40 ms |
9228 KB |
Output is correct |
14 |
Correct |
50 ms |
9212 KB |
Output is correct |
15 |
Correct |
41 ms |
9156 KB |
Output is correct |
16 |
Correct |
42 ms |
9248 KB |
Output is correct |
17 |
Correct |
38 ms |
9172 KB |
Output is correct |
18 |
Correct |
34 ms |
7548 KB |
Output is correct |
19 |
Correct |
34 ms |
7400 KB |
Output is correct |
20 |
Correct |
38 ms |
9196 KB |
Output is correct |
21 |
Correct |
39 ms |
9232 KB |
Output is correct |
22 |
Correct |
37 ms |
9200 KB |
Output is correct |
23 |
Correct |
40 ms |
9280 KB |
Output is correct |
24 |
Correct |
39 ms |
9200 KB |
Output is correct |
25 |
Correct |
33 ms |
7472 KB |
Output is correct |
26 |
Correct |
38 ms |
9128 KB |
Output is correct |
27 |
Correct |
44 ms |
9200 KB |
Output is correct |
28 |
Correct |
38 ms |
9224 KB |
Output is correct |
29 |
Correct |
33 ms |
7332 KB |
Output is correct |
30 |
Correct |
44 ms |
9184 KB |
Output is correct |
31 |
Correct |
34 ms |
7332 KB |
Output is correct |
32 |
Correct |
39 ms |
9108 KB |
Output is correct |
33 |
Correct |
39 ms |
9124 KB |
Output is correct |