結果

問題 No.3822 Permuted Pairwise XOR
コンテスト
ユーザー Rho
提出日時 2026-11-08 01:39:50
言語 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  
実行時間 20 ms / 2,000 ms
+ 683µs
コード長 1,826 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,272 ms
コンパイル使用メモリ 385,328 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-11-22 12:37:18
合計ジャッジ時間 5,458 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//# pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ull=unsigned long long;
typedef pair<ll,ll> P;
#define vec vector
#define pb emplace_back
#define fs first
#define sc second
#define pcnt __builtin_popcountll
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rng(i,s,t) for(ll i=s;i<t;i++)
#define len(a) int((a).size())
#define all(a) a.begin(),a.end()
#define compress(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
constexpr ll INF=4e18;
constexpr ld EPS=1e-11;
template<typename T> bool inline chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool inline chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename itr> void printvec(itr begin, itr end) {
	for (itr p = begin; p < end; p++){
		if(p!=begin)cout<<" "; cout << *p;
	}
	cout << endl;
}
template <class T> T makevec(T value) {return value;}
template <class T, class... Args,
		std::enable_if_t<(sizeof...(Args) > 0), int> = 0>
auto makevec(std::size_t n, Args... args) {
	auto inner = makevec<T>(args...);
	return std::vector<decltype(inner)>(n, inner);
}

#include "atcoder/modint.hpp"
using namespace atcoder;
typedef modint998244353 mint;
const ll mod=998244353;

int main(){
	ll n;
	cin>>n;
	vec<ll>a(n);
	rep(i,n) cin>>a[i];

	vec<vec<ll>>b(n),c(n);
	rep(i,n){
		vec<ll>cnt(n);
		cnt[i]=1;
		c[i].push_back(a[i]);
		ll cur=a[i];
		rep(j,n-1){
			ll mx=-1,idx=-1;
			rep(k,n){
				if(cnt[k]==0&&chmax(mx,a[k]^cur))idx=k;
			}
			cnt[idx]=1;
			c[i].push_back(a[idx]);
			b[i].push_back(a[idx]^cur);
			cur=a[idx];
		}
	}
	vec<pair<vec<ll>,vec<ll>>> res;
	rep(i,n){
		res.push_back({b[i],c[i]});
	}
	auto ans=*max_element(all(res));
	printvec(all(ans.second));
}
0