結果

問題 No.2171 OR Assignment
ユーザー mkawa2mkawa2
提出日時 2022-12-23 23:22:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 684 ms / 3,500 ms
コード長 1,175 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 109,128 KB
最終ジャッジ日時 2023-08-11 13:39:58
合計ジャッジ時間 12,388 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,672 KB
testcase_01 AC 95 ms
71,788 KB
testcase_02 AC 93 ms
71,604 KB
testcase_03 AC 94 ms
71,740 KB
testcase_04 AC 93 ms
71,764 KB
testcase_05 AC 95 ms
71,492 KB
testcase_06 AC 93 ms
71,812 KB
testcase_07 AC 94 ms
71,688 KB
testcase_08 AC 95 ms
71,776 KB
testcase_09 AC 95 ms
71,868 KB
testcase_10 AC 95 ms
71,868 KB
testcase_11 AC 94 ms
71,604 KB
testcase_12 AC 279 ms
109,128 KB
testcase_13 AC 282 ms
108,784 KB
testcase_14 AC 277 ms
108,976 KB
testcase_15 AC 179 ms
105,136 KB
testcase_16 AC 208 ms
105,736 KB
testcase_17 AC 190 ms
108,824 KB
testcase_18 AC 443 ms
108,056 KB
testcase_19 AC 446 ms
105,756 KB
testcase_20 AC 551 ms
105,780 KB
testcase_21 AC 595 ms
105,992 KB
testcase_22 AC 572 ms
105,852 KB
testcase_23 AC 547 ms
107,260 KB
testcase_24 AC 684 ms
107,324 KB
testcase_25 AC 654 ms
106,892 KB
testcase_26 AC 630 ms
106,380 KB
testcase_27 AC 534 ms
106,436 KB
testcase_28 AC 546 ms
106,624 KB
testcase_29 AC 519 ms
107,128 KB
testcase_30 AC 576 ms
107,916 KB
testcase_31 AC 613 ms
107,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

from collections import Counter

n = II()
aa = LI()

dp = Counter()
for i, a in enumerate(aa):
    s = i == 0
    px = -1
    ndp = Counter()
    for x in sorted(dp, reverse=True):
        nx = x | a
        if nx != px and px != -1: ndp[px] = s
        s += dp[x]
        s %= md
        px = nx
    if px != -1: ndp[px] = s
    if px != a: ndp[a] = s
    dp = ndp
    # pDB(dp)

ans = 0
for v in dp.values():
    ans += v
    ans %= md

print(ans)
0