結果

問題 No.2171 OR Assignment
ユーザー titiatitia
提出日時 2022-12-25 01:36:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,233 ms / 3,500 ms
コード長 845 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 106,080 KB
最終ジャッジ日時 2023-08-11 15:17:07
合計ジャッジ時間 33,381 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,144 KB
testcase_01 AC 70 ms
71,200 KB
testcase_02 AC 70 ms
71,212 KB
testcase_03 AC 69 ms
71,336 KB
testcase_04 AC 70 ms
71,272 KB
testcase_05 AC 70 ms
71,280 KB
testcase_06 AC 72 ms
71,188 KB
testcase_07 AC 70 ms
71,188 KB
testcase_08 AC 71 ms
71,308 KB
testcase_09 AC 70 ms
71,296 KB
testcase_10 AC 69 ms
71,144 KB
testcase_11 AC 69 ms
71,244 KB
testcase_12 AC 439 ms
100,700 KB
testcase_13 AC 443 ms
100,616 KB
testcase_14 AC 445 ms
100,820 KB
testcase_15 AC 273 ms
104,804 KB
testcase_16 AC 288 ms
104,560 KB
testcase_17 AC 320 ms
101,112 KB
testcase_18 AC 1,165 ms
101,096 KB
testcase_19 AC 1,143 ms
104,940 KB
testcase_20 AC 1,986 ms
104,488 KB
testcase_21 AC 2,071 ms
105,140 KB
testcase_22 AC 2,135 ms
104,428 KB
testcase_23 AC 2,015 ms
106,080 KB
testcase_24 AC 1,980 ms
106,036 KB
testcase_25 AC 1,959 ms
105,464 KB
testcase_26 AC 3,233 ms
105,604 KB
testcase_27 AC 1,688 ms
105,384 KB
testcase_28 AC 1,922 ms
105,676 KB
testcase_29 AC 1,766 ms
105,856 KB
testcase_30 AC 1,526 ms
105,588 KB
testcase_31 AC 1,917 ms
105,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

prev=[0]*30

mod=998244353

IND=[0]
DP=[1]

for i in range(1,N):
    NDP=[]
    NIND=[]
    a=A[i]
    
    for j in range(30):
        if (1<<j) & a!= 0:
            prev[j]=i

    sp=sorted(set(prev)|{i},reverse=True)
    SA=[a]*len(sp)
    now=a
    for j in range(len(sp)):
        now|=A[sp[j]]
        SA[j]=now

    s=i

    for j in range(len(SA)):
        if j+1<len(SA) and SA[j]==SA[j+1]:
            continue
        else:      
            score=0
            for ix in range(len(IND)):
                if IND[ix]<=s:
                    score=(score+DP[ix])%mod

            NDP.append(score)
            NIND.append(sp[j])

            if j+1<len(sp):
                s=sp[j+1]

    DP=NDP
    IND=NIND
    #print(DP,IND)

print(sum(DP)%mod)
0