結果

問題 No.2672 Subset Xor Sum
コンテスト
ユーザー GOTKAKO
提出日時 2026-10-23 07:10:14
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 63 ms / 2,000 ms
+ 155µs
コード長 643 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,291 ms
コンパイル使用メモリ 215,176 KB
実行使用メモリ 9,916 KB
最終ジャッジ日時 2026-10-23 07:10:20
合計ジャッジ時間 6,164 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    int Xor = 0;
    vector<int> A(N);
    for(auto &a : A) cin >> a,Xor ^= a;
    if(Xor){cout << "No" << endl; return 0;}
    if(N >= 5001){cout << "Yes" << endl; return 0;}

    bool yes = false;
    bitset<8192> dp;
    for(int i=0; i<N-1; i++){
        int a = A.at(i);
        bitset<8192> dp2;
        for(int k=0; k<8192; k++) if(dp.test(k)) dp2.set(k^a);
        dp |= dp2,dp.set(a);
        if(dp.test(0)) yes = true;
    }
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0