結果

問題 No.2672 Subset Xor Sum
ユーザー 沙耶花
提出日時 2024-03-15 21:25:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 4,066 ms
コンパイル使用メモリ 251,428 KB
最終ジャッジ日時 2025-02-20 04:35:34
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 66
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n;
	cin>>n;
	
	vector<long long> a(n);
	rep(i,n)cin>>a[i];
	long long s = 0;
	rep(i,n){
		s ^= a[i];
	}
	if(s!=0)cout<<"No"<<endl;
	else{
		if(n>=30){
			cout<<"Yes"<<endl;
		}
		else{
			vector<long long> dp(8192,0);
			dp[0] = 1;
			rep(i,n){
				vector<long long> ndp(8192,0);
				rep(j,8192){
					ndp[j] += dp[j];
					ndp[j] += dp[j^a[i]];
				}
				swap(dp,ndp);
			}
			if(dp[0]==2)cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
		}
	}
	
	return 0;
}
0