結果

問題 No.3822 Permuted Pairwise XOR
コンテスト
ユーザー Sqrt10
提出日時 2026-11-08 02:07:49
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 26 ms / 2,000 ms
+ 434µs
コード長 747 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,933 ms
コンパイル使用メモリ 364,188 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-11-22 12:37:21
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
	int n;
	int a[305];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	vector<pair<vector<int>, vector<int>>> t;
	for (int i = 0; i < n; i++) {
		vector<int> s, u;
		bool b[305] = {};
		b[i] = true;
		s.push_back(a[i]);
		for (int j = 0; j < n - 1; j++) {
			int m = -1;
			int idx = -1;
			for (int k = 0; k < n; k++) {
				if (b[k]) continue;
				int l = s.back() ^ a[k];
				if (l > m) {
					m = l;
					idx = k;
				}
			}
			s.push_back(a[idx]);
			u.push_back(m);
			b[idx] = true;
		}
		t.push_back({u, s});
	}
	auto p = (*max_element(t.begin(), t.end())).second;
	for (int i = 0; i < n; i++) {
		cout << p[i];
		if (i == n - 1)
			cout << endl;
		else
			cout << ' ';
	}
}
0