結果
| 問題 |
No.2672 Subset Xor Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-09 00:12:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 339 ms / 2,000 ms |
| コード長 | 738 bytes |
| コンパイル時間 | 2,061 ms |
| コンパイル使用メモリ | 198,980 KB |
| 最終ジャッジ日時 | 2025-02-20 03:18:43 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
if (N > 5001) {
cout << "Yes" << endl;
return 0;
}
vector<vector<long long> > dp(N + 1, vector<long long>(8192, 1e9));
dp[1][A[0]] = 1;
for (int i = 2; i <= N; i++) {
int a = A[i - 1];
for (int x = 0; x < 8192; x++) {
dp[i][x] = min(dp[i - 1][x], dp[i - 1][x ^ a] + 1);
}
}
if (dp[N][0] < N) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}