結果
| 問題 |
No.3219 Ruler to Maximize
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-01 21:58:41 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 944 bytes |
| コンパイル時間 | 2,573 ms |
| コンパイル使用メモリ | 282,040 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-01 21:58:47 |
| 合計ジャッジ時間 | 3,979 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
const uint MAX_A = bit_ceil((uint)4000);
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n; cin >> n;
vector<uint> a(n);
for (uint &x : a) cin >> x;
vector<bool> col(n, false);
uint ans = 0;
for (uint i = 1; i < MAX_A; i++) {
uint w = 0, b = 0;
vector<bool> tmp(n, false);
for (int j = 0; j < n; j++) {
if ((i & a[j]) == 0) {
b |= a[j];
tmp[j] = true;
} else if ((i & a[j]) == a[j]) {
w |= a[j];
} else {
w = 0; b = 0;
break;
}
}
if (w * b > ans) {
ans = w * b;
col = tmp;
}
}
cout << ans << "\n";
for (int i = 0; i < n; i++) {
cout << (col[i] ? "W" : "B");
}
cout << endl;
return 0;
}