結果
問題 |
No.2672 Subset Xor Sum
|
ユーザー |
|
提出日時 | 2024-03-13 20:57:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 155 ms / 2,000 ms |
コード長 | 744 bytes |
コンパイル時間 | 2,058 ms |
コンパイル使用メモリ | 195,660 KB |
最終ジャッジ日時 | 2025-02-20 04:14:13 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 66 |
ソースコード
#include <bits/stdc++.h> using namespace std; vector<int> A; bool rec(int i = 0, int cnt = 0, int sxor = 0) { if (i == int(A.size())) { if (sxor == 0 && 1 <= cnt && cnt < int(A.size())) return true; else return false; } else { if (rec(i + 1, cnt, sxor)) return true; if (rec(i + 1, cnt + 1, sxor ^ A[i])) return true; return false; } } int main() { int N; cin >> N; A.resize(N); for (int &x : A) cin >> x; int xorsum = 0; for (int &x : A) xorsum ^= x; if (xorsum) { cout << "No" << endl; return 0; } if (rec()) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }