結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー deark1414deark1414
提出日時 2017-10-05 17:25:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 301 ms / 5,000 ms
コード長 612 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 64,656 KB
実行使用メモリ 163,740 KB
最終ジャッジ日時 2023-09-12 15:16:57
合計ジャッジ時間 3,977 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
163,364 KB
testcase_01 AC 43 ms
163,380 KB
testcase_02 AC 43 ms
163,420 KB
testcase_03 AC 43 ms
163,544 KB
testcase_04 AC 42 ms
163,380 KB
testcase_05 AC 44 ms
163,404 KB
testcase_06 AC 42 ms
163,516 KB
testcase_07 AC 301 ms
163,572 KB
testcase_08 AC 272 ms
163,404 KB
testcase_09 AC 206 ms
163,612 KB
testcase_10 AC 236 ms
163,408 KB
testcase_11 AC 291 ms
163,740 KB
testcase_12 AC 43 ms
163,536 KB
testcase_13 AC 42 ms
163,488 KB
testcase_14 AC 43 ms
163,356 KB
testcase_15 AC 297 ms
163,696 KB
testcase_16 AC 42 ms
163,540 KB
testcase_17 AC 104 ms
163,388 KB
testcase_18 AC 280 ms
163,380 KB
testcase_19 AC 73 ms
163,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>

using namespace std;
const int lim = 1<<15;
bool dp[5001][lim+1];
int main(){
	memset(dp,0,sizeof(dp));
	int n;
	cin >> n;
	
	vector<int> a;
	for(int i = 0;i < n;i++){
		int ta;
		cin >> ta;
		if(find(a.begin(),a.end(),ta) == a.end()) a.push_back(ta);
	}
	
	dp[0][0] = true;
	for(int i = 0;i < a.size();i++){
		for(int j = 0;j <= lim;j++){
			if(dp[i][j]){
				dp[i+1][j] = true;
				dp[i+1][j ^ a[i]] = true;
			}
		}
	}
	
	int ans = 0;
	for(int i = 0;i <= lim;i++){
		if(dp[a.size()][i]) ans++;
	}
	
	cout << ans << endl;
	return 0;
}
0