結果

問題 No.2672 Subset Xor Sum
ユーザー suisensuisen
提出日時 2024-03-16 18:25:10
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 896 ms
コンパイル使用メモリ 75,136 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-09-30 04:32:08
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 66
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

bool solve(const int n, const std::vector<int> &a) {
    int x = 0;
    for (int e : a) x ^= e;
    if (x) return false;
    std::vector<int> b;
    for (int i = 0; i < n; ++i) {
        int e = a[i];
        for (int v : b) e = std::min(e, e ^ v);
        if (e) {
            b.push_back(e);
            continue;
        }
        return i != n - 1;
    }
    return false;
}

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

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;

    std::cout << (solve(n, a) ? "Yes" : "No") << std::endl;
}
0