結果

問題 No.130 XOR Minimax
ユーザー ttkkggwwttkkggww
提出日時 2022-05-10 17:31:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,265 ms / 5,000 ms
コード長 955 bytes
コンパイル時間 4,364 ms
コンパイル使用メモリ 269,184 KB
実行使用メモリ 17,432 KB
最終ジャッジ日時 2023-09-24 23:41:12
合計ジャッジ時間 13,979 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 449 ms
9,168 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 168 ms
14,000 KB
testcase_07 AC 170 ms
14,156 KB
testcase_08 AC 1,265 ms
17,432 KB
testcase_09 AC 34 ms
5,224 KB
testcase_10 AC 49 ms
5,836 KB
testcase_11 AC 124 ms
10,276 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 107 ms
9,280 KB
testcase_14 AC 983 ms
15,080 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 656 ms
11,380 KB
testcase_17 AC 680 ms
11,576 KB
testcase_18 AC 735 ms
12,224 KB
testcase_19 AC 890 ms
14,520 KB
testcase_20 AC 397 ms
8,560 KB
testcase_21 AC 944 ms
15,008 KB
testcase_22 AC 157 ms
5,768 KB
testcase_23 AC 43 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;

void solve(){
	using P = pair<ll,ll>;
	map<ll,ll> mpa;
	for(auto &i:a)mpa[i] = 0;;
	ll rbit = (1ll<<40)-1,lbit = 0;

	for(int i = 0;i<40;i++){
		
		//for(auto &[l,r]:mpa)cout<<l<<' '<<r<<endl;
		{
			rbit -= (1ll<<i);
			vector<ll> b;
			for(auto &[l,r]:mpa)b.push_back(l&rbit);
			map<ll,ll> mpb;
			for(auto &j:b){
				ll k = j+(1ll<<i);
				//cout<<"jk:"<<j<<' '<<k<<endl;
				if(mpa.count(j)+mpa.count(k)==2){
					mpb[j] = min(mpa[k],mpa[j])+(1ll<<i);
				}else if(mpa.count(j)){
					mpb[j] = mpa[j];
				}else{
					mpb[j] = mpa[k];
				}
			}
			swap(mpa,mpb);
		}
		//cout<<endl;
	}
	//for(auto &[l,r]:mpa)cout<<l<<' '<<r<<endl;cout<<endl;
	for(auto &[l,r]:mpa)cout<<r<<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