結果

問題 No.2171 OR Assignment
ユーザー titia
提出日時 2022-12-25 01:32:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 105,856 KB
最終ジャッジ日時 2024-11-18 08:41:52
合計ジャッジ時間 26,925 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17 WA * 13
権限があれば一括ダウンロードができます

ソースコード

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),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(sum(DP)%mod)
0