結果
| 問題 | 
                            No.3219 Ruler to Maximize
                             | 
                    
| コンテスト | |
| ユーザー | 
                             zawakasu
                         | 
                    
| 提出日時 | 2025-08-01 21:43:15 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,611 bytes | 
| コンパイル時間 | 1,230 ms | 
| コンパイル使用メモリ | 120,680 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-08-01 21:43:35 | 
| 合計ジャッジ時間 | 5,734 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 1 WA * 31 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <tuple>
#include <ranges>
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 = (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) {
            ans = W * B;
            S = T;
        }
    }
    cout << ans << '\n' << S << '\n';
}
            
            
            
        
            
zawakasu