結果

問題 No.2672 Subset Xor Sum
コンテスト
ユーザー nu50218
提出日時 2024-03-13 20:56:52
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 559 ms / 2,000 ms
+ 757µs
コード長 740 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,266 ms
コンパイル使用メモリ 214,920 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-10-16 18:32:36
合計ジャッジ時間 17,981 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 67
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
    }

    bool ans = false;

    for (int s = 1; s < (1 << min(N, 23)); s++) {
        int bitcnt = 0;
        int sxor = 0;
        for (int bit = 0; bit < min(N, 23); bit++) {
            if (s & (1 << bit)) {
                bitcnt += 1;
                sxor ^= A[bit];
            }
        }
        if (sxor == 0 && 1 <= bitcnt && bitcnt < N) ans = true;
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
0