結果

問題 No.2672 Subset Xor Sum
ユーザー GOTKAKO
提出日時 2024-03-15 21:36:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 657 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 196,324 KB
最終ジャッジ日時 2025-02-20 04:41:55
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35 RE * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#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<5001> ok;
    for(int i=0; i<N; i++){
        int a = A.at(i);
        if(ok.test(a) && i != N-1) yes = true;


        bitset<5001> ok2;
        for(int k=0; k<=5000; k++) if(ok.test(k)) ok2.set(k^a);
        ok |= ok2; ok.set(a);
    }
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0