結果

問題 No.130 XOR Minimax
ユーザー ttkkggwwttkkggww
提出日時 2022-05-10 15:59:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 961 bytes
コンパイル時間 4,422 ms
コンパイル使用メモリ 260,424 KB
実行使用メモリ 4,804 KB
最終ジャッジ日時 2023-09-24 21:33:19
合計ジャッジ時間 7,371 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 36 ms
4,632 KB
testcase_05 AC 44 ms
4,616 KB
testcase_06 AC 40 ms
4,804 KB
testcase_07 WA -
testcase_08 AC 43 ms
4,796 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 10 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 25 ms
4,376 KB
testcase_14 AC 36 ms
4,544 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 24 ms
4,376 KB
testcase_17 AC 25 ms
4,376 KB
testcase_18 AC 27 ms
4,380 KB
testcase_19 AC 33 ms
4,464 KB
testcase_20 AC 16 ms
4,384 KB
testcase_21 AC 35 ms
4,548 KB
testcase_22 WA -
testcase_23 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
ll n;
vector<ll> a;

ll dp[40][2];
ll dpx[40][2];

void solve(){
	for(ll i = 40-2;i>=0;i--){
		for(ll j = 0;j<2;j++){//to
			ll mn = LLONG_MAX/2;
			for(ll k = 0;k<2;k++){//from
				auto b = a;
				for(auto &l :b)l ^= dpx[i+1][k]+(j<<i);
				ll mnb = b[0];
				for(auto &l:b)mnb = max(mnb,l);
				if(mn>mnb){
					mn = mnb;
					dpx[i][j] = dpx[i+1][k] + (j<<i);
				}
			}
		}
	}
	ll mn = LLONG_MAX/2;
	{
		auto b = a;
		for(auto &l:b)l ^= dpx[0][0];
		ll mxb = b[0];
		for(auto &l:b)mxb = max(l,mxb);
		mn = min(mn,mxb);
	}
	{
		auto b = a;
		for(auto &l:b)l ^= dpx[0][1];
		ll mxb = b[0];
		for(auto &l:b)mxb = max(l,mxb);
		mn = min(mn,mxb);
	}
	//cout<<dpx[0][0] << ' '<<dpx[0][1]<<endl;
	cout<<mn<<endl;
	
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n;
	a = vector<ll>(n);
	for(auto &i:a)cin >> i;
	solve();
}
0