結果
| 問題 |
No.3219 Ruler to Maximize
|
| コンテスト | |
| ユーザー |
zawakasu
|
| 提出日時 | 2025-08-01 21:48:21 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,651 bytes |
| コンパイル時間 | 1,198 ms |
| コンパイル使用メモリ | 120,552 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-01 21:48:24 |
| 合計ジャッジ時間 | 3,140 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#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 = 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';
}
zawakasu