結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー kroton
提出日時 2016-04-17 12:05:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 242 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 55,008 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 13:35:26
合計ジャッジ時間 2,557 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
using namespace std;
const int lim = 1 << 15;

bool dp[2][lim];
int main(){
	int N;
	cin >> N;

	int cur = 0, nxt = 1;
	dp[cur][0] = true;
	for(int t=0;t<N;t++){
		int A;
		cin >> A;
		memset(dp[nxt], false, sizeof(dp[nxt]));
		for(int m=0;m<lim;m++){
			dp[nxt][m] |= dp[cur][m];
			dp[nxt][m ^ A] |= dp[cur][m];
		}
		swap(cur, nxt);
	}
	int res = 0;
	for(int m=0;m<lim;m++){
		res += dp[cur][m];
	}
	cout << res << endl;
	return 0;
}
0