結果
問題 |
No.2672 Subset Xor Sum
|
ユーザー |
|
提出日時 | 2024-03-15 22:19:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 777 bytes |
コンパイル時間 | 1,711 ms |
コンパイル使用メモリ | 197,220 KB |
最終ジャッジ日時 | 2025-02-20 05:24:32 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 61 WA * 1 RE * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) void solve() { ll n; cin >> n; vector<ll> a(n), cnt(5050); ll s = 0; bool t = false; rep(i, n) { cin >> a[i]; cnt[a[i]]++; s ^= a[i]; t |= cnt[a[i]] >= 2; } if (s) { cout << "No" << '\n'; return; } if (t || cnt[0]) { cout << "Yes" << '\n'; return; } vector<int> dp(5050); dp[a[0]] = 1; for (int i = 1; i < n - 1; i++) { vector<int> p = dp; rep(j, 5030) if (p[j]) dp[j ^ a[i]] = true; } cout << (dp[0] ? "Yes" : "No") << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }