結果

問題 No.1741 Arrays and XOR Procedure
ユーザー 👑 Kazun
提出日時 2021-11-12 23:36:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 105,728 KB
最終ジャッジ日時 2024-11-25 22:01:33
合計ジャッジ時間 4,749 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

def greedy(A):
    while len(A)>1:
        B=[]
        for i in range(len(A)-1):
            B.append(A[i]^A[i+1])
        A=B
    return A[0]

def nCr_mod2(n,r):
    return 1 if n|r==n else 0
#==================================================
N=int(input())
B=list(map(int,input().split()))

F=[nCr_mod2(N-1,r) for r in range(N)]
Mod=998244353

DP=[1,0]
for i,b in enumerate(B):
    E=DP.copy()
    if b==-1:
        if F[i]==0:
            DP[0]=2*DP[0]%Mod
            DP[1]=2*DP[1]%Mod
        else:
            DP[0]=DP[1]=(DP[0]+DP[1])%Mod
    elif b==1 and F[i]==1:
        DP=E[::-1]

print(DP[1])
0