#include #include #include #include #include #include #include #include #include namespace ranges = std::ranges; namespace views = std::views; // #include "Src/Number/IntegerDivision.hpp" // #include "Src/Utility/BinarySearch.hpp" // #include "Src/Sequence/CompressedSequence.hpp" // #include "Src/Sequence/RunLengthEncoding.hpp" // #include "Src/Algebra/Group/AdditiveGroup.hpp" // #include "Src/DataStructure/FenwickTree/FenwickTree.hpp" // #include "Src/DataStructure/SegmentTree/SegmentTree.hpp" // #include "Src/DataStructure/DisjointSetUnion/DisjointSetUnion.hpp" // using namespace zawa; // #include "atcoder/modint" // using mint = atcoder::modint998244353; using namespace std; int N, A[100]; bool is_subset(int s, int S) { return (s | (S ^ s)) == S; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin >> N; for (int i = 0 ; i < N ; i++) cin >> A[i]; int ans = 0; string S(N, 'W'); for (int b = 0 ; b < (1 << 12) ; b++) { int W = 0, B = 0; bool ok = true; string T; const int msk = b ^ ((1 << 12) - 1); for (int i = 0 ; i < N ; i++) { if (is_subset(A[i], b)) { W |= A[i]; T += 'W'; } else if (is_subset(A[i], msk)) { B |= A[i]; T += 'B'; } else ok = false; } if (ok and ans < W * B) { assert((W & B) == 0); ans = W * B; S = T; } } cout << ans << '\n' << S << '\n'; }