結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー HachimoriHachimori
提出日時 2015-04-17 21:07:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 168 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 65,292 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 11:05:29
合計ジャッジ時間 2,151 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 168 ms
4,380 KB
testcase_08 AC 85 ms
4,376 KB
testcase_09 AC 59 ms
4,376 KB
testcase_10 AC 71 ms
4,376 KB
testcase_11 AC 93 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 95 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 22 ms
4,384 KB
testcase_18 AC 163 ms
4,380 KB
testcase_19 AC 12 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
#include<numeric>
using namespace std;
const int VAL = 5005;
const int RANGE = (1 << 15) + 5;


int nVal, val[VAL];

void read() {
    cin >> nVal;
    for (int i = 0; i < nVal; ++i)
        cin >> val[i];
}


void work() {
    bool visited[RANGE] = {};
    queue<int> Q;
    
    visited[0] = true;
    Q.push(0);
    
    while (!Q.empty()) {
        int cur = Q.front();
        Q.pop();
        
        for (int i = 0; i < nVal; ++i) {
            int nex = cur ^ val[i];
            if (!visited[nex]) {
                visited[nex] = true;
                Q.push(nex);
            }
        }
    }
    
    cout << accumulate(visited, visited + RANGE, 0) << endl;
}


int main() {
    read();
    work();
    return 0;
}
0