結果

問題 No.2171 OR Assignment
ユーザー suisensuisen
提出日時 2022-12-23 01:39:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 345 ms / 3,500 ms
コード長 503 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 107,264 KB
最終ジャッジ日時 2024-04-29 05:52:59
合計ジャッジ時間 7,278 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,968 KB
testcase_01 AC 41 ms
51,840 KB
testcase_02 AC 41 ms
51,712 KB
testcase_03 AC 41 ms
51,712 KB
testcase_04 AC 41 ms
51,712 KB
testcase_05 AC 42 ms
51,584 KB
testcase_06 AC 41 ms
51,712 KB
testcase_07 AC 42 ms
51,840 KB
testcase_08 AC 41 ms
51,712 KB
testcase_09 AC 41 ms
51,584 KB
testcase_10 AC 42 ms
51,584 KB
testcase_11 AC 41 ms
51,840 KB
testcase_12 AC 220 ms
102,016 KB
testcase_13 AC 218 ms
101,632 KB
testcase_14 AC 206 ms
101,760 KB
testcase_15 AC 131 ms
103,680 KB
testcase_16 AC 168 ms
103,936 KB
testcase_17 AC 151 ms
101,376 KB
testcase_18 AC 253 ms
107,008 KB
testcase_19 AC 238 ms
103,936 KB
testcase_20 AC 342 ms
103,936 KB
testcase_21 AC 334 ms
103,808 KB
testcase_22 AC 291 ms
104,320 KB
testcase_23 AC 280 ms
105,984 KB
testcase_24 AC 307 ms
105,984 KB
testcase_25 AC 304 ms
105,344 KB
testcase_26 AC 296 ms
105,088 KB
testcase_27 AC 292 ms
104,960 KB
testcase_28 AC 345 ms
105,216 KB
testcase_29 AC 341 ms
106,240 KB
testcase_30 AC 284 ms
107,264 KB
testcase_31 AC 295 ms
106,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P = 998244353

N = int(input())
A = list(map(int, input().split()))

ppos = []
pd = [1]
for i, v in enumerate(A):
    pos = [i]
    for j in reversed(ppos):
        nv = v | A[j]
        if nv != v:
            v = nv
            pos.append(j)
    pos.reverse()

    siz = len(pos)
    dp = [0] * (siz + 1)
    j = 0
    for k in range(siz):
        while j < len(ppos) and ppos[j] <= pos[k]:
            j += 1
        dp[k + 1] = dp[k] + pd[j]
    pd = [v % P for v in dp]
    ppos = pos
print(pd[-1])
0