結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー takune1024
提出日時 2017-11-27 23:27:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 397 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 66,276 KB
実行使用メモリ 144,948 KB
最終ジャッジ日時 2024-06-30 03:27:29
合計ジャッジ時間 3,766 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> P;
typedef unsigned long long ll;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const int inf = 999999999;
const int mod = 1000000007;

bool dp[5010][1 << 15];

int main(){
	int n; cin >> n;
	int a[n];
	Rep(i, n) cin >> a[i];
	dp[0][0] = true;
	Rep(i, n) Rep(j, 1 << 15){
		if((j ^ a[i]) >= 0){
			if(dp[i][j ^ a[i]] || dp[i][j]) dp[i + 1][j] = true;
		}else{
			if(dp[i][j]) dp[i + 1][j] = true;
		}
	}
	int ans = 0;
	Rep(j, 1 << 15){
		if(dp[n][j]) ans += 1;
	}
	cout << ans << endl;
	return 0;
}
0