結果

問題 No.1741 Arrays and XOR Procedure
ユーザー 👑 KazunKazun
提出日時 2021-11-12 22:32:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 104,404 KB
最終ジャッジ日時 2024-05-04 09:49:39
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,204 KB
testcase_01 AC 35 ms
52,644 KB
testcase_02 AC 37 ms
52,136 KB
testcase_03 AC 97 ms
104,284 KB
testcase_04 AC 33 ms
53,688 KB
testcase_05 AC 96 ms
103,684 KB
testcase_06 AC 108 ms
103,908 KB
testcase_07 AC 101 ms
104,404 KB
testcase_08 AC 97 ms
103,932 KB
testcase_09 AC 97 ms
100,764 KB
testcase_10 AC 96 ms
100,584 KB
testcase_11 AC 87 ms
95,160 KB
testcase_12 AC 80 ms
90,536 KB
testcase_13 AC 97 ms
100,360 KB
testcase_14 AC 87 ms
92,376 KB
testcase_15 AC 89 ms
97,360 KB
testcase_16 AC 51 ms
73,944 KB
testcase_17 AC 67 ms
83,240 KB
testcase_18 AC 86 ms
92,688 KB
testcase_19 AC 48 ms
70,312 KB
testcase_20 AC 97 ms
104,052 KB
testcase_21 AC 84 ms
97,628 KB
testcase_22 AC 82 ms
95,028 KB
testcase_23 AC 64 ms
81,888 KB
testcase_24 AC 49 ms
74,140 KB
testcase_25 AC 95 ms
104,064 KB
testcase_26 AC 68 ms
85,592 KB
testcase_27 AC 47 ms
69,076 KB
testcase_28 AC 83 ms
95,152 KB
testcase_29 AC 91 ms
97,708 KB
testcase_30 AC 83 ms
95,040 KB
testcase_31 AC 48 ms
68,712 KB
testcase_32 AC 72 ms
85,248 KB
testcase_33 AC 76 ms
88,688 KB
testcase_34 AC 58 ms
80,076 KB
testcase_35 AC 39 ms
58,796 KB
testcase_36 AC 55 ms
76,776 KB
testcase_37 AC 71 ms
85,612 KB
testcase_38 AC 104 ms
103,688 KB
testcase_39 AC 75 ms
83,972 KB
testcase_40 AC 49 ms
64,792 KB
testcase_41 AC 61 ms
79,404 KB
testcase_42 AC 51 ms
71,612 KB
testcase_43 AC 33 ms
53,208 KB
権限があれば一括ダウンロードができます

ソースコード

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):
    while (n>0) or (r>0):
        if n&1==0 and r&1==1:
            return 0
        n>>=1; r>>=1
    return 1
#==================================================
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