#include "Anna.h"
#include "bits/stdc++.h"
using namespace std;
#define ll long long
const int B = 89;
ll dp[B][2];
void Anna(int n, vector<char> s) {
int f = -1;
for(int i=0;i<n;i++){
if(s[i] == 'X') { f = i; break; }
}
if(f == -1) return;
vector<int> res(n);
res[f] = 1;
for(int i=f+2;i<n;i++){
if(s[i] == 'Z') res[i] = 1;
if(s[i] == 'Z' && s[i-1] == 'Z') res[i-1] = 0;
}
dp[0][0] = dp[0][1] = 1;
for(int i=1;i<B;i++){
dp[i][0] = dp[i-1][0] + dp[i-1][1];
dp[i][1] = dp[i-1][0];
}
//~ auto get = [&](vector<int> x) {
//~ ii res = (ii)0;
//~ for(int i=0;i<(int)x.size();i++){
//~ if(x[i]) res += dp[i][0];
//~ } return res;
//~ };
//~ for(int i=0;i<n;i++) cout<<res[i]<<" ";
//~ cout<<"\n";
int C = (n + B - 1) / B;
vector<int> rr;
for(int i=0;i<C;i++){
vector<int> tmp = vector<int>(res.begin() + i * B, res.begin() + min(n, (i + 1) * B));
ll v = 0;
for(int i=0;i<(int)tmp.size();i++){
if(tmp[i]) v = v + dp[i][0];
}
for(int j=0;j<64;j++){
Send(v >> j & 1);
}
}
}
#include "Bruno.h"
#include "bits/stdc++.h"
using namespace std;
#define ll long long
const int B = 89;
void Bruno(int n, int l, vector<int> a) {
ll dp[B][2] {};
dp[0][0] = dp[0][1] = 1;
for(int i=1;i<B;i++){
dp[i][0] = dp[i-1][0] + dp[i-1][1];
dp[i][1] = dp[i-1][0];
}
int C = (n + B - 1) / B;
vector<int> is(n);
for(int i=0;i<C;i++){
ll v = 0;
for(int j=i*64;j<(i+1)*64;j++){
v |= ((a[j] * 1ll) << j);
}
for(int l=B-1;~l;l--){
if(v >= dp[l][0]) is[i * B + l] = 1, v -= dp[l][0];
}
}
//~ for(int i=0;i<n;i++) cout<<is[i]<<" ";
//~ cout<<"\n";
int last = -1, f = -1;
for(int i=0;i<n;i++){
if(~f){
if(is[i]){
int j = i - 1;
while(j > last) Remove(j), j--;
Remove(i); last = i;
}
} else {
if(is[i]) f = last = i;
else Remove(i);
}
}
int j = n - 1;
while(j > last) Remove(j), j--;
Remove(f);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
580 KB |
Output is correct |
3 |
Correct |
0 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
572 KB |
Output is correct |
5 |
Correct |
0 ms |
492 KB |
Output is correct |
6 |
Correct |
0 ms |
496 KB |
Output is correct |
7 |
Correct |
1 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
472 KB |
Output is correct |
9 |
Correct |
1 ms |
668 KB |
Output is correct |
10 |
Runtime error |
0 ms |
616 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
48 ms |
8452 KB |
Partially correct |
2 |
Partially correct |
54 ms |
8284 KB |
Partially correct |
3 |
Incorrect |
49 ms |
8400 KB |
Wrong Answer [6] |
4 |
Halted |
0 ms |
0 KB |
- |