結果
| 問題 |
No.2672 Subset Xor Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-23 16:52:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 126 ms / 2,000 ms |
| コード長 | 1,519 bytes |
| コンパイル時間 | 3,422 ms |
| コンパイル使用メモリ | 248,040 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-20 18:54:13 |
| 合計ジャッジ時間 | 7,976 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 66 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/modint>
using namespace std;
//using namespace atcoder;
//using mint = modint998244353;
#define rep(i,n) for(long long i=0;i<n;i++)
#define rep1(i,n) for(long long i=1;i<=n;i++)
#define Rep(i,a,b) for(long long i=a;i<=b;i++)
#define all(a) (a).begin(), (a).end()
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vvec;
typedef vector<long long> vecll;
typedef vector<vector<long long>> vvecll;
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
const ll mod=998244353;
//const ll mod=1e9+7;
const ll INF=5e18;
const int INT_INF=1e9;
const double pi=3.14159265358979;
//xのn乗をpで割ったあまりを求める
ll modpow(ll x,ll n,ll p=mod){
if(n==0) return 1;
if(n%2==1) return (x*modpow(x,n-1,p))%p;
else{
ll t=modpow(x,n/2,p);
assert(t>0);
return (t*t)%p;
}
}
//xの逆元(p:素数)
ll inv(ll x,ll p=mod){
return modpow(x,p-2,p);
}
template <typename T>
int index(vector<T> &a, T x){
return lower_bound(all(a),x)-a.begin();
}
int main(){
int n;
cin >> n;
vec a(n);
rep(i,n) cin >> a[i];
int s=0;
rep(i,n) s^=a[i];
if(s!=0){
cout << "No" << endl;
return 0;
}
vector<int> dp(1<<13,0);
dp[a[0]]=1;
rep1(i,n-2){
if(dp[0]) break;
vector<int> ndp=dp;
rep(j,1<<13){
ndp[a[i]^j]|=dp[j];
}
dp=move(ndp);
}
cout << (dp[0]?"Yes":"No") << endl;
return 0;
}