結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー tomorrowtomorrow
提出日時 2022-05-19 23:16:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 183 ms / 5,000 ms
コード長 941 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 204,340 KB
実行使用メモリ 164,108 KB
最終ジャッジ日時 2023-10-19 07:43:01
合計ジャッジ時間 4,297 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,844 KB
testcase_01 AC 3 ms
5,940 KB
testcase_02 AC 3 ms
6,164 KB
testcase_03 AC 3 ms
6,100 KB
testcase_04 AC 3 ms
5,876 KB
testcase_05 AC 3 ms
6,196 KB
testcase_06 AC 2 ms
5,972 KB
testcase_07 AC 159 ms
147,596 KB
testcase_08 AC 158 ms
148,140 KB
testcase_09 AC 101 ms
103,200 KB
testcase_10 AC 121 ms
123,240 KB
testcase_11 AC 175 ms
160,240 KB
testcase_12 AC 3 ms
6,228 KB
testcase_13 AC 2 ms
5,720 KB
testcase_14 AC 183 ms
164,108 KB
testcase_15 AC 168 ms
164,108 KB
testcase_16 AC 3 ms
6,100 KB
testcase_17 AC 38 ms
41,200 KB
testcase_18 AC 141 ms
144,216 KB
testcase_19 AC 20 ms
24,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll inf = (1LL << 62);
template <typename T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T& a, const T& b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
char dp[5010][1 << 15];
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < (1 << 15); ++j) {
            //if(dp[i][j] == 1){
            //    dp[i+1][j] = 1;
            //} else {
            //
            //}
            dp[i + 1][j] = dp[i][j ^ a[i]] | dp[i][j];
        }
    }
    ll cnt = 0;
    for (ll i = 0; i < (1 << 15); ++i) {
        if (dp[n][i] == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
}
0