結果

問題 No.183 たのしい排他的論理和(EASY)
コンテスト
ユーザー d_nishiyama85
提出日時 2016-07-09 20:59:10
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 739 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 575 ms
コンパイル使用メモリ 76,816 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-19 03:16:21
合計ジャッジ時間 2,331 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <vector>
#include <iostream>

using namespace std;
#define MAX (1<<15)


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

    now[0] = true;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < MAX; j++)
        {
            if (now[j]) {
              int num = j ^ A[i];
              nex[num] = true;
            }
            nex[j] |= now[j];
        }

        for (int j = 0; j < MAX; j++)
        {
            now[j] |= nex[j];
        }
    }

    for (int i = 0; i < MAX; i++)
    {
        if (now[i]) ans++;
    }


    cout << ans << endl;
    //cout << (1ll << ans) << endl;
}
0