結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー exaluckexaluck
提出日時 2018-11-16 02:19:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 437 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 68,880 KB
実行使用メモリ 23,416 KB
最終ジャッジ日時 2023-09-13 20:39:55
合計ジャッジ時間 4,298 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 437 ms
21,028 KB
testcase_08 AC 318 ms
20,972 KB
testcase_09 AC 218 ms
15,488 KB
testcase_10 AC 266 ms
17,916 KB
testcase_11 AC 348 ms
22,680 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 204 ms
23,300 KB
testcase_15 AC 362 ms
23,416 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 81 ms
7,632 KB
testcase_18 AC 381 ms
20,772 KB
testcase_19 AC 40 ms
5,256 KB
権限があれば一括ダウンロードができます

ソースコード

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