結果

問題 No.1741 Arrays and XOR Procedure
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-11-12 22:17:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 119,148 KB
最終ジャッジ日時 2023-08-17 02:00:45
合計ジャッジ時間 7,504 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,256 KB
testcase_01 AC 72 ms
71,488 KB
testcase_02 AC 73 ms
71,376 KB
testcase_03 AC 145 ms
119,080 KB
testcase_04 AC 74 ms
71,108 KB
testcase_05 AC 145 ms
118,988 KB
testcase_06 AC 155 ms
118,904 KB
testcase_07 AC 155 ms
118,912 KB
testcase_08 AC 143 ms
119,076 KB
testcase_09 AC 143 ms
114,104 KB
testcase_10 AC 143 ms
114,064 KB
testcase_11 AC 148 ms
108,568 KB
testcase_12 AC 134 ms
102,284 KB
testcase_13 AC 143 ms
113,652 KB
testcase_14 AC 149 ms
104,656 KB
testcase_15 AC 136 ms
109,420 KB
testcase_16 AC 100 ms
77,388 KB
testcase_17 AC 116 ms
90,344 KB
testcase_18 AC 145 ms
105,240 KB
testcase_19 AC 93 ms
76,752 KB
testcase_20 AC 153 ms
119,148 KB
testcase_21 AC 148 ms
110,508 KB
testcase_22 AC 136 ms
108,544 KB
testcase_23 AC 113 ms
88,396 KB
testcase_24 AC 97 ms
76,684 KB
testcase_25 AC 150 ms
118,796 KB
testcase_26 AC 118 ms
95,072 KB
testcase_27 AC 93 ms
76,748 KB
testcase_28 AC 138 ms
108,864 KB
testcase_29 AC 141 ms
109,548 KB
testcase_30 AC 145 ms
108,748 KB
testcase_31 AC 93 ms
76,812 KB
testcase_32 AC 123 ms
94,312 KB
testcase_33 AC 126 ms
99,968 KB
testcase_34 AC 105 ms
84,148 KB
testcase_35 AC 76 ms
71,308 KB
testcase_36 AC 92 ms
77,304 KB
testcase_37 AC 119 ms
94,800 KB
testcase_38 AC 150 ms
117,480 KB
testcase_39 AC 123 ms
91,592 KB
testcase_40 AC 90 ms
76,776 KB
testcase_41 AC 111 ms
83,456 KB
testcase_42 AC 105 ms
77,852 KB
testcase_43 AC 72 ms
71,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
B = list(map(int,input().split()))
mod = 998244353

two = [0]
for i in range(1,n+1):
    count = 0
    num = i
    while num%2 == 0:
        num //= 2
        count += 1
    two.append(two[-1]+count)


def nCr(n,r):
    if two[n] > two[r]+two[n-r]:
        return 1
    return 0

ans = 1
dp = [0]*2
dp[0] = 1
for i,b in enumerate(B):
    ndp = [0]*2
    even = nCr(n-1,i)
    if b != 1:
        ndp[0] += dp[0]
        ndp[1] += dp[1]

    if b != 0:
        if even:
            ndp[0] += dp[0]
            ndp[1] += dp[1]
        else:
            ndp[1] += dp[0]
            ndp[0] += dp[1]
    dp = ndp
    dp[0] %= mod
    dp[1] %= mod
print(dp[1])

        

0