結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
|
提出日時 | 2024-03-15 22:23:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 844 bytes |
コンパイル時間 | 1,976 ms |
コンパイル使用メモリ | 197,700 KB |
最終ジャッジ日時 | 2025-02-20 05:28:07 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 66 |
ソースコード
#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 (n == 2 && a[0]) {cout << "No" << '\n';return;}if (t || cnt[0]) {cout << "Yes" << '\n';return;}vector<int> dp(10000);dp[a[0]] = 1;for (int i = 1; i < n - 1; i++) {vector<int> p = dp;rep(j, 9000) 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;}