結果
| 問題 |
No.2672 Subset Xor Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-16 18:25:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 655 bytes |
| コンパイル時間 | 606 ms |
| コンパイル使用メモリ | 73,560 KB |
| 最終ジャッジ日時 | 2025-02-20 06:57:06 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 66 |
ソースコード
#include <iostream>
#include <vector>
bool solve(const int n, const std::vector<int> &a) {
int x = 0;
for (int e : a) x ^= e;
if (x) return false;
std::vector<int> b;
for (int i = 0; i < n; ++i) {
int e = a[i];
for (int v : b) e = std::min(e, e ^ v);
if (e) {
b.push_back(e);
continue;
}
return i != n - 1;
}
return false;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n);
for (auto &e : a) std::cin >> e;
std::cout << (solve(n, a) ? "Yes" : "No") << std::endl;
}