結果

問題 No.2171 OR Assignment
ユーザー 👑 hitonanodehitonanode
提出日時 2023-01-02 23:40:29
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 582 ms / 3,500 ms
コード長 1,162 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 93,732 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 06:49:50
合計ジャッジ時間 7,945 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 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 1 ms
5,376 KB
testcase_12 AC 136 ms
5,376 KB
testcase_13 AC 139 ms
5,376 KB
testcase_14 AC 131 ms
5,376 KB
testcase_15 AC 23 ms
5,376 KB
testcase_16 AC 28 ms
5,376 KB
testcase_17 AC 42 ms
5,376 KB
testcase_18 AC 170 ms
5,376 KB
testcase_19 AC 143 ms
5,376 KB
testcase_20 AC 262 ms
5,376 KB
testcase_21 AC 274 ms
5,376 KB
testcase_22 AC 354 ms
5,376 KB
testcase_23 AC 473 ms
5,376 KB
testcase_24 AC 582 ms
5,376 KB
testcase_25 AC 503 ms
5,376 KB
testcase_26 AC 436 ms
5,376 KB
testcase_27 AC 404 ms
5,376 KB
testcase_28 AC 453 ms
5,376 KB
testcase_29 AC 487 ms
5,376 KB
testcase_30 AC 534 ms
5,376 KB
testcase_31 AC 490 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

constexpr int D = 30;

constexpr int md = (119 << 23) + 1;

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);
    int N;
    cin >> N;

    vector<int> prvs(D + 1, 0), js;

    vector<pair<int, int>> dp;
    dp.emplace_back(0, 1);

    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        REP(d, D) {
            if ((a >> d) & 1) prvs.at(d) = i;
        }
        prvs.back() = i;
        decltype(dp) dpnxt;

        for (int j : prvs) {
            if (j <= 0) continue;
            bool found = false;
            for (const auto &[k, v] : dpnxt) {
                if (k == j) found = true;
            }
            if (found) continue;
            long long sum = 0;
            for (auto [jprv, cnt] : dp) {
                if (jprv <= j) sum += cnt;
            }
            dpnxt.emplace_back(j, sum % md);
        }
        dp = dpnxt;
    }
    long long ret = 0;
    for (auto [k, v] : dp) ret += v;
    cout << ret % md << endl;
}
0