結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー mizunomidorimizunomidori
提出日時 2016-07-03 22:47:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 979 ms / 5,000 ms
コード長 918 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 78,120 KB
実行使用メモリ 204,332 KB
最終ジャッジ日時 2023-09-12 00:56:31
合計ジャッジ時間 6,060 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 979 ms
204,332 KB
testcase_08 AC 518 ms
151,840 KB
testcase_09 AC 357 ms
105,036 KB
testcase_10 AC 429 ms
126,140 KB
testcase_11 AC 563 ms
165,076 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 583 ms
170,784 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 129 ms
39,956 KB
testcase_18 AC 943 ms
175,312 KB
testcase_19 AC 65 ms
21,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

#define N_MAX 5000

using namespace std;


int main(void)
{
    int N, A[N_MAX];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    bool *can_make = new bool[1 << 15]();
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        if (can_make[x]) {
            continue;
        }
        can_make[x] = true;
        for (int i = 0; i < N; i++) {
            int y = x ^ A[i];
            if (!can_make[y]) {
                q.push(y);
            }
        }
    }
    cout << accumulate(can_make, can_make + (1 << 15), 0) << endl;
    return 0;
}
0