結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー Eliza_0xEliza_0x
提出日時 2018-05-13 15:11:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 890 ms / 5,000 ms
コード長 766 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 66,660 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 19:03:37
合計ジャッジ時間 6,732 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 4 ms
4,384 KB
testcase_03 AC 4 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 445 ms
4,380 KB
testcase_08 AC 594 ms
4,380 KB
testcase_09 AC 409 ms
4,380 KB
testcase_10 AC 494 ms
4,384 KB
testcase_11 AC 648 ms
4,384 KB
testcase_12 AC 4 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 890 ms
4,380 KB
testcase_15 AC 675 ms
4,384 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 152 ms
4,380 KB
testcase_18 AC 503 ms
4,384 KB
testcase_19 AC 76 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <bitset>
using namespace std;

int main() {
    const int size = 40000;
    int n; cin >> n;
    vector<int> ns(n);
    for (auto &&x: ns) cin >> x;
    bitset<size+1> memo;
    for (int y = 0; y<(n+1); y++) {
        for (int x = 0; x<size+1; x++) {
            if      (y==0 && x==0) memo[x] = true;
            else if (y==0)         memo[x] = false;
            else memo[x] = memo[x] || (((x^ns[y-1]) < size) ? memo[x^ns[y-1]] : false);
        }
    }

    // for (int x = 0; x<25; x++) cout << setw(3) << x; cout << endl;
    // for (int x = 0; x<25; x++) cout << setw(3) << memo[x]; cout << endl;

    int cnt = 0;
    for (int x = 0; x<size+1; x++) cnt += memo[x];
    cout << cnt << endl;
}
0