結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
|
提出日時 | 2024-03-08 19:56:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 728 bytes |
コンパイル時間 | 1,768 ms |
コンパイル使用メモリ | 172,104 KB |
実行使用メモリ | 101,120 KB |
最終ジャッジ日時 | 2024-09-29 23:35:24 |
合計ジャッジ時間 | 5,690 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}