結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー takune1024takune1024
提出日時 2017-11-27 23:27:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 293 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 67,148 KB
実行使用メモリ 144,544 KB
最終ジャッジ日時 2023-09-12 15:31:16
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,376 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 239 ms
144,544 KB
testcase_08 AC 250 ms
109,464 KB
testcase_09 AC 165 ms
82,152 KB
testcase_10 AC 201 ms
102,264 KB
testcase_11 AC 271 ms
125,208 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 293 ms
82,724 KB
testcase_15 AC 280 ms
132,696 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 59 ms
39,500 KB
testcase_18 AC 209 ms
141,024 KB
testcase_19 AC 29 ms
21,012 KB
権限があれば一括ダウンロードができます

ソースコード

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