結果

問題 No.2171 OR Assignment
ユーザー suisensuisen
提出日時 2022-12-23 01:26:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 3,500 ms
コード長 1,127 bytes
コンパイル時間 978 ms
コンパイル使用メモリ 84,860 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 05:51:52
合計ジャッジ時間 3,689 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 62 ms
5,376 KB
testcase_13 AC 61 ms
5,376 KB
testcase_14 AC 61 ms
5,376 KB
testcase_15 AC 23 ms
5,376 KB
testcase_16 AC 30 ms
5,376 KB
testcase_17 AC 35 ms
5,376 KB
testcase_18 AC 73 ms
5,376 KB
testcase_19 AC 63 ms
5,376 KB
testcase_20 AC 78 ms
5,376 KB
testcase_21 AC 80 ms
5,376 KB
testcase_22 AC 84 ms
5,376 KB
testcase_23 AC 89 ms
5,376 KB
testcase_24 AC 94 ms
5,376 KB
testcase_25 AC 93 ms
5,376 KB
testcase_26 AC 91 ms
5,376 KB
testcase_27 AC 89 ms
5,376 KB
testcase_28 AC 90 ms
5,376 KB
testcase_29 AC 92 ms
5,376 KB
testcase_30 AC 91 ms
5,376 KB
testcase_31 AC 88 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <iostream>
#include <vector>

#include <atcoder/modint>

using mint = atcoder::modint998244353;

constexpr int L = 30;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (auto &&e : a) std::cin >> e;

    std::vector<int> ppos;
    std::vector<mint> pd { 1 };
    for (int i = 0; i < n; ++i) {
        std::vector<int> pos { i };
        int orv = a[i];
        for (auto it = ppos.rbegin(); it != ppos.rend(); ++it) {
            const int p = *it, norv = orv | a[p];
            if (norv != orv) {
                pos.push_back(p);
                orv = norv;
            }
        }
        std::reverse(pos.begin(), pos.end());

        const int siz = pos.size();
        std::vector<mint> dp(siz + 1);
        for (int k = 0, j = 0; k < siz; ++k) {
            while (j < int(ppos.size()) and ppos[j] <= pos[k]) ++j;
            dp[k + 1] = dp[k] + pd[j];
        }
        pd.swap(dp);
        ppos.swap(pos);
    }
    std::cout << pd.back().val() << std::endl;
    return 0;
}
0