結果

問題 No.3219 Ruler to Maximize
コンテスト
ユーザー Iroha_3856
提出日時 2025-08-01 22:46:00
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 714µs
コード長 468 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,697 ms
コンパイル使用メモリ 340,224 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-11-12 03:08:19
合計ジャッジ時間 5,244 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> A(N); for (int& a : A) cin >> a;
	
	int ans = 0;
	int y = 0;
	for (int x = 0; x < 4096; x++) {
		int w = 0, b = 0;
		for (int a : A) {
			if ((a|x) == x) w |= a;
			else b |= a;
		}
		if ((w&b) != 0) continue;
		if (ans < w * b) {
			ans = w * b;
			y = x;
		}
	}
	
	cout << ans << endl;
	for (int a : A) {
		if ((a|y) == y) cout << "W";
		else cout << "B";
	}
	cout << endl;
}
0