結果

問題 No.2672 Subset Xor Sum
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2024-03-15 23:21:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 2,646 ms
コンパイル使用メモリ 245,580 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-09-30 04:25:26
合計ジャッジ時間 4,415 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 66
権限があれば一括ダウンロードができます

ソースコード

diff #

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


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

    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a: A) cin >> a;
    int x = 0;
    for (auto a: A) x^= a;

    if (x){
        cout << "No" << endl;
        return 0;
    }

    int M = 16;

    if (n > M){
        cout << "Yes" << endl;
        return 0;
    }

    for (int i = 1; i < (1<<n)-1; i++){
        int x = 0;
        for (int j = 0; j < n; j++){
            if (i >> j & 1) x ^= A[j];
        }
        if (x == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}
0