結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
|
提出日時 | 2024-02-11 18:27:04 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 290 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 3,439 ms |
コンパイル使用メモリ | 165,324 KB |
実行使用メモリ | 323,328 KB |
最終ジャッジ日時 | 2024-09-30 04:09:12 |
合計ジャッジ時間 | 8,603 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}