結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
![]() |
提出日時 | 2024-03-17 20:20:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 285 ms / 2,000 ms |
コード長 | 749 bytes |
コンパイル時間 | 2,102 ms |
コンパイル使用メモリ | 200,428 KB |
最終ジャッジ日時 | 2025-02-20 07:04:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 66 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int N;cin >> N;int xor_all = 0;vector<int> A(N);for( int i = 0; i < N; i++ ) {cin >> A[i];xor_all ^= A[i];}if( xor_all != 0 ) {cout << "No" << endl;return 0;}if( N > 5001 ) {cout << "Yes" << endl;return 0;}const int M = 1<<13;vector dp(4, vector<int>(M, false));vector ep(4, vector<int>(M, false));dp[0][0] = true;for( int i = 0; i < N; i++ ) {for( int x = 0; x < 4; x++ ) for( int y = 0; y < M; y++ ) {ep[x|(1<<0)][y] |= dp[x][y];ep[x|(1<<1)][y^A[i]] |= dp[x][y];}swap(dp, ep);fill(ep.begin(), ep.end(), vector<int>(M, false));}cout << ( dp[3][0] ? "Yes" : "No" ) << endl;}