結果
問題 |
No.2672 Subset Xor Sum
|
ユーザー |
|
提出日時 | 2024-03-13 21:02:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 728 bytes |
コンパイル時間 | 1,844 ms |
コンパイル使用メモリ | 197,380 KB |
最終ジャッジ日時 | 2025-02-20 04:15:01 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 53 WA * 13 |
ソースコード
#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<int> > dp(N + 1, vector<int>(5001, 1e9)); dp[1][A[0]] = 1; for (int i = 2; i <= N; i++) { int a = A[i - 1]; for (int x = 0; x < 5001; 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; }