結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

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

	int rank = 0;
	long long row = 0;
	for(int col=0; col<64; col++){
		int pivot = row;
		while( ((a[pivot] >> col) & 1) == false && pivot < n) pivot++;
		if( pivot >= n || ((a[pivot] >> col) & 1) == false ) continue;
		swap(a[row], a[pivot]);
		for(int i=row+1; i<n; i++){
			if(a[i] >> col & 1) a[i] ^= a[row];
		}

		row++;
		rank++;
	}

	cout << (1LL<<rank) << endl;

	return 0;
}
0