結果

問題 No.1741 Arrays and XOR Procedure
ユーザー 👑 KazunKazun
提出日時 2021-11-12 22:32:57
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 105,464 KB
最終ジャッジ日時 2023-08-17 02:38:28
合計ジャッジ時間 6,809 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,468 KB
testcase_01 AC 69 ms
71,392 KB
testcase_02 AC 69 ms
71,184 KB
testcase_03 AC 137 ms
105,464 KB
testcase_04 AC 68 ms
71,340 KB
testcase_05 AC 136 ms
105,096 KB
testcase_06 AC 142 ms
105,396 KB
testcase_07 AC 142 ms
105,176 KB
testcase_08 AC 133 ms
104,788 KB
testcase_09 AC 133 ms
101,972 KB
testcase_10 AC 139 ms
101,656 KB
testcase_11 AC 125 ms
95,896 KB
testcase_12 AC 116 ms
91,516 KB
testcase_13 AC 133 ms
101,832 KB
testcase_14 AC 122 ms
93,556 KB
testcase_15 AC 124 ms
98,752 KB
testcase_16 AC 91 ms
77,576 KB
testcase_17 AC 110 ms
84,108 KB
testcase_18 AC 131 ms
93,672 KB
testcase_19 AC 92 ms
76,868 KB
testcase_20 AC 143 ms
105,112 KB
testcase_21 AC 125 ms
98,760 KB
testcase_22 AC 118 ms
95,940 KB
testcase_23 AC 101 ms
83,256 KB
testcase_24 AC 89 ms
77,648 KB
testcase_25 AC 135 ms
104,940 KB
testcase_26 AC 102 ms
86,828 KB
testcase_27 AC 83 ms
76,820 KB
testcase_28 AC 121 ms
96,144 KB
testcase_29 AC 130 ms
99,136 KB
testcase_30 AC 122 ms
96,240 KB
testcase_31 AC 84 ms
77,020 KB
testcase_32 AC 112 ms
86,488 KB
testcase_33 AC 113 ms
89,580 KB
testcase_34 AC 95 ms
80,900 KB
testcase_35 AC 75 ms
75,312 KB
testcase_36 AC 89 ms
77,888 KB
testcase_37 AC 103 ms
86,844 KB
testcase_38 AC 140 ms
104,936 KB
testcase_39 AC 105 ms
85,244 KB
testcase_40 AC 85 ms
76,888 KB
testcase_41 AC 98 ms
80,388 KB
testcase_42 AC 89 ms
76,884 KB
testcase_43 AC 70 ms
71,136 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