結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー data9824
提出日時 2015-05-22 20:31:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 192 ms / 5,000 ms
コード長 593 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 62,420 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-29 02:00:14
合計ジャッジ時間 2,613 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	bool available[2][1 << 15] = { false };
	available[0][0] = true;
	for (int i = 0; i < n; ++i) {
		for (size_t x = 0; x < (1 << 15); ++x) {
			if (available[i % 2][x]) {
				int newX = x ^ a[i];
				available[(i + 1) % 2][newX] = true;
				available[(i + 1) % 2][x] = true;
			}
		}
	}
	int result = count(&available[n % 2][0], &available[n % 2][(1 << 15) - 1] + 1, true);
	cout << result << endl;
	return 0;
}
0