結果
| 問題 |
No.2672 Subset Xor Sum
|
| コンテスト | |
| ユーザー |
nono00
|
| 提出日時 | 2024-03-15 21:38:22 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 1,189 bytes |
| コンパイル時間 | 2,656 ms |
| コンパイル使用メモリ | 250,856 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-09-30 04:15:09 |
| 合計ジャッジ時間 | 4,985 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 66 |
ソースコード
#include <bits/stdc++.h>
namespace nono {
void solve() {
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; i++) std::cin >> a[i];
int all = 0;
for (int i = 0; i < n; i++) all ^= a[i];
if (all != 0) {
std::cout << "No" << '\n';
return;
}
const int MAX_A = 10005;
std::vector<bool> used(MAX_A);
for (int i = 0; i < n; i++) {
if (used[a[i]] && n > 2) {
std::cout << "Yes" << '\n';
return;
}
used[a[i]] = true;
}
std::vector<bool> cur(MAX_A);
for (int i = 0; i + 1 < n; i++) {
if (cur[a[i]]) {
std::cout << "Yes" << '\n';
return;
}
std::vector<bool> next(MAX_A);
next[a[i]] = true;
for (int j = 0; j < MAX_A; j++) {
if (cur[j]) {
next[j] = true;
next[j ^ a[i]] = true;
}
}
cur = std::move(next);
}
std::cout << "No" << '\n';
}
} // namespace nono
int main() {
std::cin.tie(0)->sync_with_stdio(0);
std::cout << std::fixed << std::setprecision(16);
int t = 1;
while (t--) nono::solve();
}
nono00