#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; }
}
int C = (n + B - 1) / B;
if(f == -1){
return;
}
//~ cout<<f<<" "<<n<<" "<<s[0]<<endl;
for(int i=0;i<18;i++) Send(f >> i & 1);
vector<int> res(n);
//~ res[f] = 1;
for(int i=f+1;i<n;i++){
if(s[i] == 'Z'){
res[i] = 1;
if(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";
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<63;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];
}
//~ cout<<n<<" "<<l<<endl;
if(!l){
for(int i=0;i<n;i++) Remove(i);
return;
}
int f = 0;
for(int i=0;i<18;i++) f |= (a[i] << i);
a.erase(a.begin(), a.begin() + 18);
//~ cout<<f<<endl;
int C = (n + B - 1) / B;
//~ assert((int)a.size() == C * 63);
//~ cout<<"here"<<endl;
vector<int> is(C * B);
for(int i=0;i<C;i++){
ll v = 0;
for(int j=i*63;j<(i+1)*63;j++){
v |= ((a[j] * 1ll) << (j - i*63));
}
for(int l=B-1;~l;l--){
if(v >= dp[l][0]) is[i * B + l] = 1, v -= dp[l][0];
}
//~ cout<<"here"<<endl;
}
for(int i=0;i<f;i++) Remove(i);
int last = f; //, f = -1;
for(int i=f+1;i<n;i++){
if(is[i]){
int j = i - 1;
while(j > last) Remove(j--);
Remove(i); last = i;
}
}
int j = n - 1;
while(j > last) Remove(j--);
Remove(f);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
496 KB |
Output is correct |
2 |
Correct |
1 ms |
580 KB |
Output is correct |
3 |
Correct |
1 ms |
496 KB |
Output is correct |
4 |
Correct |
1 ms |
496 KB |
Output is correct |
5 |
Correct |
1 ms |
584 KB |
Output is correct |
6 |
Correct |
0 ms |
496 KB |
Output is correct |
7 |
Correct |
1 ms |
488 KB |
Output is correct |
8 |
Correct |
1 ms |
496 KB |
Output is correct |
9 |
Correct |
0 ms |
496 KB |
Output is correct |
10 |
Correct |
1 ms |
500 KB |
Output is correct |
11 |
Correct |
1 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
48 ms |
8284 KB |
Partially correct |
2 |
Partially correct |
46 ms |
8364 KB |
Partially correct |
3 |
Partially correct |
49 ms |
8260 KB |
Partially correct |
4 |
Partially correct |
48 ms |
8304 KB |
Partially correct |
5 |
Partially correct |
57 ms |
8252 KB |
Partially correct |
6 |
Partially correct |
49 ms |
8460 KB |
Partially correct |
7 |
Partially correct |
46 ms |
8324 KB |
Partially correct |
8 |
Partially correct |
49 ms |
8360 KB |
Partially correct |
9 |
Partially correct |
48 ms |
8332 KB |
Partially correct |
10 |
Partially correct |
47 ms |
8448 KB |
Partially correct |
11 |
Partially correct |
47 ms |
8284 KB |
Partially correct |
12 |
Partially correct |
47 ms |
8376 KB |
Partially correct |
13 |
Partially correct |
55 ms |
8272 KB |
Partially correct |
14 |
Partially correct |
55 ms |
8296 KB |
Partially correct |
15 |
Partially correct |
51 ms |
8296 KB |
Partially correct |
16 |
Partially correct |
49 ms |
8292 KB |
Partially correct |
17 |
Partially correct |
59 ms |
8300 KB |
Partially correct |
18 |
Correct |
44 ms |
6760 KB |
Output is correct |
19 |
Correct |
43 ms |
6764 KB |
Output is correct |
20 |
Partially correct |
47 ms |
8508 KB |
Partially correct |
21 |
Partially correct |
46 ms |
8508 KB |
Partially correct |
22 |
Partially correct |
54 ms |
8280 KB |
Partially correct |
23 |
Partially correct |
46 ms |
8480 KB |
Partially correct |
24 |
Partially correct |
49 ms |
8360 KB |
Partially correct |
25 |
Correct |
41 ms |
6744 KB |
Output is correct |
26 |
Partially correct |
54 ms |
8316 KB |
Partially correct |
27 |
Partially correct |
55 ms |
8288 KB |
Partially correct |
28 |
Partially correct |
55 ms |
8376 KB |
Partially correct |
29 |
Correct |
41 ms |
6700 KB |
Output is correct |
30 |
Partially correct |
55 ms |
8400 KB |
Partially correct |
31 |
Correct |
42 ms |
6724 KB |
Output is correct |
32 |
Partially correct |
47 ms |
8428 KB |
Partially correct |
33 |
Partially correct |
47 ms |
8316 KB |
Partially correct |