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