#include <bits/stdc++.h>
#include "Anna.h"
using namespace std;
namespace Nigga{
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ll mask){return __builtin_ctzll(mask);}
int logOf(ll mask){return __lg(mask);}
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T& container, string separator = " ", string finish = "\n"){
for(auto item: container) cout << item << separator;
cout << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
ll dp[76];
void prepare(){
dp[0] = 1; dp[1] = 2;
for(int i = 2; i<76; ++i) {
dp[i] = dp[i-1] + dp[i-2];
// cout << dp[i] << " ";
}
// cout << "\n";
}
}
// void Send(int d){cout << d << ", ";}
void Anna(int N, vector<char> S){
typedef long long ll;
typedef unsigned long long ull;
int n = N;
vector<int> a;
for(int i = 0; i<n; ++i) a.push_back(S[i] - 'X');
Nigga::prepare();
vector<bool> ans(n);
int idx = -1;
for(int i = 0; i<n; ++i) if (a[i] == 0){
ans[i] = 1;
idx = i;
break;
}
if (idx != -1){
for(int i = idx + 1; i<n; ++i) if (a[i] == 2 && (i == n - 1 || a[i+1] != 2)){
ans[i] = 1;
}
}
bool real = false;
for(int i = 1; i<n; ++i) if (ans[i] && ans[i-1]){
ans[i] = false;
real = true;
}
while(ans.size() % 76) ans.push_back(0);
for(int i = 0; i<ans.size(); i += 76){
ll s = 0;
for(int j = 0; j<76; ++j) if (ans[i + j]) s += Nigga::dp[j];
for(int j = 0; j<53; ++j) {
Send(s % 2);
s /= 2;
}
}
Send(real);
}
// int main(void){
// Anna(97, {'X', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z', 'Y', 'Z'});
// return 0;
// }
#include <bits/stdc++.h>
#include "Bruno.h"
using namespace std;
namespace Ligma{
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ll mask){return __builtin_ctzll(mask);}
int logOf(ll mask){return __lg(mask);}
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T& container, string separator = " ", string finish = "\n"){
for(auto item: container) cout << item << separator;
cout << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
ll dp[76];
void prepare(){
dp[0] = 1; dp[1] = 2;
for(int i = 2; i<76; ++i) {
dp[i] = dp[i-1] + dp[i-2];
// cout << dp[i] << " ";
}
// cout << "\n";
}
}
// void Remove(int d){cout << "Remove: " << d << "\n";}
void Bruno(int N, int L, vector<int> A){
typedef long long ll;
typedef unsigned long long ull;
Ligma::prepare();
int n = N;
vector<int> pos;
int shit = 0;
for(int i = 0; i<L-1; i += 53){
ll s = 0;
for(int j = 52; j>=0; --j) s = s * 2 + A[i+j];
for(int j = 75; j>=0; --j) if (Ligma::dp[j] <= s){
s -= Ligma::dp[j];
pos.push_back(shit + j);
}
shit += 76;
}
sort(ALL(pos));
if (A.back()){
pos.push_back(pos[0] + 1);
}
sort(ALL(pos));
// Ligma::printArr(pos);
if (pos.empty()){
for(int i = 0; i<n; ++i) Remove(i);
return;
}
for(int i = 1; i<pos.size(); ++i){
for(int j = pos[i] - 1; j > pos[i-1]; --j) Remove(j);
Remove(pos[i]);
}
for(int i = 0; i<=pos[0]; ++i) Remove(i);
for(int i = pos.back() + 1; i<n; ++i) Remove(i);
}
// int main(void){
// Bruno(97, 90, {{0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}});
// return 0;
// }
Compilation message
Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:95:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
95 | for(int i = 0; i<ans.size(); i += 76){
| ~^~~~~~~~~~~
Anna.cpp:68:28: warning: typedef 'ull' locally defined but not used [-Wunused-local-typedefs]
68 | typedef unsigned long long ull;
| ^~~
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:92:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | for(int i = 1; i<pos.size(); ++i){
| ~^~~~~~~~~~~
Bruno.cpp:67:28: warning: typedef 'ull' locally defined but not used [-Wunused-local-typedefs]
67 | typedef unsigned long long ull;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
780 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
0 ms |
780 KB |
Output is correct |
4 |
Correct |
0 ms |
792 KB |
Output is correct |
5 |
Correct |
0 ms |
796 KB |
Output is correct |
6 |
Correct |
0 ms |
796 KB |
Output is correct |
7 |
Correct |
1 ms |
796 KB |
Output is correct |
8 |
Correct |
1 ms |
784 KB |
Output is correct |
9 |
Correct |
0 ms |
808 KB |
Output is correct |
10 |
Correct |
0 ms |
780 KB |
Output is correct |
11 |
Correct |
0 ms |
872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
8584 KB |
Output is correct |
2 |
Correct |
38 ms |
8708 KB |
Output is correct |
3 |
Correct |
44 ms |
8696 KB |
Output is correct |
4 |
Correct |
38 ms |
8608 KB |
Output is correct |
5 |
Correct |
38 ms |
8696 KB |
Output is correct |
6 |
Correct |
39 ms |
8532 KB |
Output is correct |
7 |
Correct |
38 ms |
8688 KB |
Output is correct |
8 |
Correct |
39 ms |
8444 KB |
Output is correct |
9 |
Correct |
39 ms |
8660 KB |
Output is correct |
10 |
Correct |
39 ms |
8548 KB |
Output is correct |
11 |
Correct |
39 ms |
8684 KB |
Output is correct |
12 |
Correct |
42 ms |
8744 KB |
Output is correct |
13 |
Correct |
45 ms |
8760 KB |
Output is correct |
14 |
Correct |
46 ms |
8528 KB |
Output is correct |
15 |
Correct |
41 ms |
8644 KB |
Output is correct |
16 |
Correct |
43 ms |
8560 KB |
Output is correct |
17 |
Correct |
42 ms |
8768 KB |
Output is correct |
18 |
Correct |
42 ms |
8776 KB |
Output is correct |
19 |
Correct |
44 ms |
8948 KB |
Output is correct |
20 |
Correct |
38 ms |
8680 KB |
Output is correct |
21 |
Correct |
38 ms |
8668 KB |
Output is correct |
22 |
Correct |
45 ms |
8728 KB |
Output is correct |
23 |
Correct |
44 ms |
8580 KB |
Output is correct |
24 |
Correct |
39 ms |
8568 KB |
Output is correct |
25 |
Correct |
43 ms |
8696 KB |
Output is correct |
26 |
Correct |
43 ms |
8672 KB |
Output is correct |
27 |
Correct |
43 ms |
8764 KB |
Output is correct |
28 |
Correct |
43 ms |
8788 KB |
Output is correct |
29 |
Correct |
42 ms |
8684 KB |
Output is correct |
30 |
Correct |
43 ms |
8504 KB |
Output is correct |
31 |
Correct |
43 ms |
8576 KB |
Output is correct |
32 |
Correct |
43 ms |
8960 KB |
Output is correct |
33 |
Correct |
40 ms |
8780 KB |
Output is correct |