結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー exaluck
提出日時 2018-11-16 02:19:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 696 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 68,056 KB
実行使用メモリ 23,552 KB
最終ジャッジ日時 2024-07-01 05:09:39
合計ジャッジ時間 5,444 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

constexpr int inputLimit = 2 << 14;

int main()
{
	int n;
	cin >> n;

	vector<int> a(n);
	for(auto& x : a) {
		cin >> x;
	}

	vector<vector<bool>> dp(n + 1, vector<bool>(inputLimit + 1, false));
	dp[0][0] = true;
	for(auto i = 0; i < n; ++i) {
		for(auto j = 0; j <= inputLimit; ++j) {
			if(dp[i][j]) {
				dp[i + 1][j] = dp[i][j];
				dp[i + 1][j ^ a[i]] = dp[i][j];
			}
		}
	}

	int result = 0;
	for(auto i = 0; i <= inputLimit; ++i) {
		if(dp[n][i]) {
			++result;
		}
	}

	cout << result << endl;
}
0