結果

問題 No.2672 Subset Xor Sum
ユーザー i_takui_taku
提出日時 2024-03-15 21:59:58
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 78,620 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-30 01:09:17
合計ジャッジ時間 3,706 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 52 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    int now = 0;
    for (int a : A) {
        now ^= a;
    }
    if (now != 0) {
        cout << "No" << endl;
        return 0;
    }

    if (N > 5000) {
        cout << "Yes" << endl;
        return 0;
    }

    vector<int> dp(8192, 0);
    dp[0] = 1;
    for (int a : A) {
        vector<int> ndp = dp;
        for (int i = 0; i < 8192; ++i) {
            ndp[i ^ a] += dp[i];
        }
        swap(dp, ndp);
    }
    if (dp[0] >= 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
0