結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー sei0osei0o
提出日時 2017-10-17 11:12:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,483 ms / 5,000 ms
コード長 796 bytes
コンパイル時間 619 ms
コンパイル使用メモリ 80,148 KB
実行使用メモリ 282,280 KB
最終ジャッジ日時 2023-09-12 15:19:01
合計ジャッジ時間 12,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 6 ms
5,608 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 6 ms
5,644 KB
testcase_06 AC 4 ms
4,384 KB
testcase_07 AC 1,419 ms
250,224 KB
testcase_08 AC 1,330 ms
189,124 KB
testcase_09 AC 867 ms
170,084 KB
testcase_10 AC 1,110 ms
214,852 KB
testcase_11 AC 1,427 ms
245,164 KB
testcase_12 AC 6 ms
5,476 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1,456 ms
185,120 KB
testcase_15 AC 1,483 ms
255,816 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 300 ms
178,128 KB
testcase_18 AC 1,346 ms
282,280 KB
testcase_19 AC 147 ms
89,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

bool dp[5010][165000]; // dp[i][k] = a[0] ~ a[i] までで k が作れるか

int main() {
    int N;
    cin >> N;
    ll a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    dp[0][0] = true;
    for (int i = 0; i < N; i++) {
        for (int k = 0; k < 165000; k++) {
            if (dp[i][k]) {
                if ((k^a[i]) < 164000) dp[i+1][k ^ a[i]] = true;
                dp[i+1][k] = true;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 165000; i++) {
        if (dp[N][i]) ans++;
    }
    cout << ans << endl;

    return 0;
}
0