#include "Anna.h"
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;
template<class A, class B>
bool maximize(A& x, B y) {
if (x < y) return x = y, true; else return false;
}
template<class A, class B>
bool minimize(A& x, B y) {
if (x > y) return x = y, true; else return false;
}
/* END OF TEMPLATE */
const int N = 1e5 + 7;
const int BLOCK = 10;
const int bit_size = 20;
int n, m;
vector<int> bit, val_remove;
ll f[N];
vector<int> old_data, new_data;
void convert_to_longlong(vector<int> B) {
// cout<<"B : ";
// for (auto x : B) cout<<x<<" "; cout<<"\n";
ll idx = 0;
f[0] = 1;
f[1] = 1;
FOR(i, 2, BLOCK) f[i] = f[i - 1] + f[i - 2];
REP(i, 0, (int)B.size())
if (B[i] == 1) {
idx+=f[(int)B.size() - i];
}
FORD(i, bit_size, 0) Send((idx >> i) & 1);
// exit(0);
}
void Convert(vector<int> A) {
while ((int)A.size() % BLOCK != 0) A.push_back(0);
for (int i = 0; i < (int)A.size(); i+=BLOCK) {
vector<int> B;
FOR(j, i, i + BLOCK - 1) B.push_back(A[j]);
convert_to_longlong(B);
}
}
void Anna(int n, vector<char> S) {
bool kt = false;
int i = 0;
while (i < n) {
if (S[i] != 'Z') {
i++;
continue;
}
int j = i;
while (j + 1 < n && S[j + 1] == S[j]) j++;
FOR(k, i, j - 1) S[k] = 'Y';
i = j + 1;
}
bool find_X = false;
REP(i, 0, n)
if (S[i] == 'X') {
find_X = true;
REP(j, i + 1, n)
if (S[j] == 'Z') S[j] = 'X'; else break;
break;
}
vector<int> A;
bool ok = false;
for (auto x : S)
if (!ok) {
if (x == 'Y' || x == 'Z') A.push_back(0); else {
ok = true;
A.push_back(1);
}
}
else {
if (x == 'Z') A.push_back(1); else A.push_back(0);
}
if (!find_X) {
A.clear();
REP(i, 0, n) A.push_back(0);
}
old_data = A;
// cout<<"old data : ";
// for (auto x : A) cout<<x<<" "; cout<<"\n";
Convert(A);
}
#include "Bruno.h"
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;
template<class A, class B>
bool maximize(A& x, B y) {
if (x < y) return x = y, true; else return false;
}
template<class A, class B>
bool minimize(A& x, B y) {
if (x > y) return x = y, true; else return false;
}
/* END OF TEMPLATE */
const int N = 1e5 + 7;
const int BLOCK = 10;
const int bit_size = 20;
int n, m;
vector<int> bit, val_remove;
ll f[N];
vector<int> old_data, new_data;
vector<int> convert_to_array(ll idx) {
f[0] = 1;
f[1] = 1;
FOR(i, 2, BLOCK) f[i] = f[i - 1] + f[i - 2];
// cerr<<idx<<endl;
vector<int> res;
// cout<<idx<<"\n";
idx++;
REP(i, 0, BLOCK)
if (idx > f[BLOCK - i]) {
res.push_back(1);
idx-=f[BLOCK - i];
}
else {
res.push_back(0);
}
// for (auto x : res) cout<<x<<" "; cout<<"\n";
// exit(0);
return res;
}
vector<int> convert_to_array(int L, vector<int> A) {
vector<int> res;
// for (auto x : A) cerr<<x<<" "; cerr<<endl;
for (int i = 0; i < L; i+=bit_size + 1) {
ll tmp = 0;
FOR(j, i, i + bit_size) tmp = tmp * 2 + A[j];
// exit(0);
vector<int> arr = convert_to_array(tmp);
for (auto x : arr) res.push_back(x);
}
return res;
}
void Bruno(int n, int L, vector<int> A) {
A = convert_to_array(L, A);
while ((int)A.size() > n) A.pop_back();
// cout<<"new data : ";
// for (auto x : A) cout<<x<<" "; cout<<"\n";
new_data = A;
if (*mxx(all(A)) == 0) {
REP(i, 0, n) Remove(i);
return ;
}
int pos = 0;
REP(i, 0, n)
if (A[i] == 1) {
pos = i;
break;
}
REP(i, 0, pos) Remove(i);
if (pos == n - 1) {
Remove(pos);
return ;
}
int i = pos;
while (i < n) {
if (i == n - 1) break;
int j = i + 1;
while (j < n && A[j] == 0) j++;
if (j >= n) {
REP(k, i + 1, n) Remove(k);
i = n - 1;
break;
}
FORD(k, j - 1, i + 1) Remove(k);
if (j > pos) Remove(j);
i = j;
}
if (pos != i) Remove(pos);
}
Compilation message
Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:80:10: warning: unused variable 'kt' [-Wunused-variable]
80 | bool kt = false;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
784 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
0 ms |
788 KB |
Output is correct |
4 |
Correct |
0 ms |
784 KB |
Output is correct |
5 |
Correct |
0 ms |
784 KB |
Output is correct |
6 |
Correct |
0 ms |
1036 KB |
Output is correct |
7 |
Correct |
0 ms |
780 KB |
Output is correct |
8 |
Correct |
1 ms |
784 KB |
Output is correct |
9 |
Correct |
0 ms |
796 KB |
Output is correct |
10 |
Correct |
0 ms |
792 KB |
Output is correct |
11 |
Correct |
0 ms |
796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
3372 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |