結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー nu50218
提出日時 2019-09-02 21:27:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 273 ms / 5,000 ms
コード長 672 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 165,440 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 16:05:15
合計ジャッジ時間 4,649 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int MAX_A = (1 << 16);

int main() {
    int N;
    cin >> N;
    bool DP[MAX_A + 1] = {};
    DP[0] = true;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        bool DP2[MAX_A + 1] = {};
        for (int j = 0; j <= MAX_A; ++j) {
            DP2[j] = DP[j];
        }
        for (int j = 0; j <= MAX_A; ++j) {
            if (DP[j]) {
                DP2[j ^ A] = true;
            }
        }
        for (int j = 0; j <= MAX_A; ++j) {
            DP[j] = DP2[j];
        }
    }
    int ans = 0;
    for (int i = 0; i <= MAX_A; ++i) {
        ans += DP[i];
    }
    cout << ans << endl;
}
0