結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 259 ms
5,376 KB
testcase_13 AC 250 ms
5,376 KB
testcase_14 AC 267 ms
5,376 KB
testcase_15 AC 69 ms
5,376 KB
testcase_16 AC 77 ms
5,376 KB
testcase_17 AC 85 ms
5,376 KB
testcase_18 AC 454 ms
5,376 KB
testcase_19 AC 444 ms
5,376 KB
testcase_20 AC 928 ms
5,376 KB
testcase_21 AC 964 ms
5,376 KB
testcase_22 AC 1,220 ms
5,376 KB
testcase_23 AC 856 ms
5,376 KB
testcase_24 AC 1,278 ms
5,376 KB
testcase_25 AC 1,284 ms
5,376 KB
testcase_26 AC 1,288 ms
5,376 KB
testcase_27 AC 1,082 ms
5,376 KB
testcase_28 AC 1,102 ms
5,376 KB
testcase_29 AC 1,028 ms
5,376 KB
testcase_30 AC 874 ms
5,376 KB
testcase_31 AC 779 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <unordered_map>
#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);

    unordered_map<int, int> dp;
    dp[-1] = 1;

    REP(i, N) {
        int a;
        cin >> a;
        REP(d, D) {
            if ((a >> d) & 1) prvs.at(d) = i;
        }
        auto js = prvs;
        sort(js.begin(), js.end());
        js.erase(unique(js.begin(), js.end()), js.end());
        if (js.back() != i) js.push_back(i);
        reverse(js.begin(), js.end());
        if (js.back() == -1) js.pop_back();

        unordered_map<int, int> dpnxt;

        for (int j : js) {
            long long sum = 0;
            for (auto [jprv, cnt] : dp) {
                if (jprv <= j) sum += cnt;
            }
            dpnxt[j] = sum % md;
        }
        dp = dpnxt;
    }
    long long ret = 0;
    for (auto [k, v] : dp) ret += v;
    cout << ret % md << endl;
}
0