結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー Div9851KDiv9851K
提出日時 2019-07-16 22:20:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 234 ms / 5,000 ms
コード長 571 bytes
コンパイル時間 1,076 ms
コンパイル使用メモリ 144,604 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 23:34:33
合計ジャッジ時間 3,779 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 228 ms
4,376 KB
testcase_08 AC 211 ms
4,376 KB
testcase_09 AC 146 ms
4,376 KB
testcase_10 AC 177 ms
4,376 KB
testcase_11 AC 228 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 188 ms
4,376 KB
testcase_15 AC 234 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 54 ms
4,376 KB
testcase_18 AC 215 ms
4,380 KB
testcase_19 AC 28 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
bool dp[2][1 << 15];
int A[5000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < (1 << 15); j++) {
			if (!dp[i & 1][j]) continue;
			dp[(i + 1) & 1][j] |= dp[i & 1][j];
			dp[(i + 1) & 1][j^A[i]] |= dp[i & 1][j];
		}
		for (int j = 0; j < (1 << 15); j++) dp[i & 1][j] = 0;
	}
	int ans = 0;
	for (int i = 0; i < (1 << 15); i++) if (dp[N & 1][i]) ans++;
	cout << ans << endl;
}
0