結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー tkzw_21
提出日時 2015-04-17 18:54:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 463 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 159,816 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-04 11:34:21
合計ジャッジ時間 3,995 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(void){
	int n;
	cin >> n;
	vector<long long> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	long long r = 0;
	for(int i=0;i<61;i++){
		int t = -1;
		for(int j=r;j<n;j++){
			if((1LL<<i) & a[j]){
				t = j;
				break;
			}
		}
		if(t == -1)continue;
		swap(a[r],a[t]);
		for(int j=0;j<n;j++){
			if(r != j){
				if(a[j] & (1LL<<i))a[j] ^= a[r];
			}
		}
		r++;
	}
	cout << (1LL<<r) << endl;
	
	return 0;
}
0