#include "Azzurro.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
// グローバル変数と内部関数は無名名前空間内で宣言すること
// All global variables and internal functions should be declared in an unnamed namespace
}
std::vector<std::vector<int>> Azzurro(int N, int L, std::string S) {
vector<vector<int>> res(N, vector<int>(N, 0));
for (int i = L; i < 51; i++) S += "A";
int cnt = 0;
for (int i = 1; i < 14; i++) {
int crnt = 0, valj = -1;
for (int j = 0; j < N; j++) {
if (i - j < 0 || i - j >= 8) continue;
if (valj == -1) {
valj = j;
continue;
}
res[j][i - j] = (S[cnt++] == 'B');
if ((j - valj) % 2 == 0) crnt = (crnt ^ res[j][i - j]);
}
res[valj][i - valj] = crnt;
}
res[0][0] = (S[49] == 'A');
res[7][7] = (S[50] == 'A');
return res;
}
#include "Bordeaux.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
// グローバル変数と内部関数は無名名前空間内で宣言すること
// All global variables and internal functions should be declared in an unnamed namespace
}
std::string Bordeaux(int N, int L, std::vector<std::vector<int>> T) {
string s;
int prevj = 0;
for (int i = 1; i < 14; i++) {
int crnt = 0, valj = -1;
for (int j = 0; j < N; j++) {
if (i - j < 0 || i - j >= 8) continue;
if (valj == -1) {
valj = j;
continue;
}
if ((j - valj) % 2 == 0) crnt = (crnt ^ T[j][i - j]);
}
if (T[valj][i - valj] != crnt) prevj += (prevj - valj + 2) % 2;
else prevj += (prevj - valj + 3) % 2;
T[prevj][i - prevj] = !T[prevj][i - prevj];
for (int j = valj + 1; j < N; j++) {
if (i - j < 0 || i - j >= 8) continue;
s += (T[j][i - j] ? "B" : "A");
}
}
s += (T[0][0] ? "B" : "A");
s += (T[7][7] ? "B" : "A");
return s.substr(0, L);
}