結果

問題 No.1741 Arrays and XOR Procedure
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-11-12 22:17:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 118,272 KB
最終ジャッジ日時 2024-05-04 09:15:09
合計ジャッジ時間 5,543 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,400 KB
testcase_01 AC 39 ms
51,840 KB
testcase_02 AC 38 ms
51,840 KB
testcase_03 AC 114 ms
118,272 KB
testcase_04 AC 38 ms
51,968 KB
testcase_05 AC 116 ms
117,632 KB
testcase_06 AC 122 ms
118,016 KB
testcase_07 AC 123 ms
117,888 KB
testcase_08 AC 114 ms
117,632 KB
testcase_09 AC 113 ms
112,824 KB
testcase_10 AC 113 ms
113,024 KB
testcase_11 AC 118 ms
109,696 KB
testcase_12 AC 105 ms
103,040 KB
testcase_13 AC 111 ms
112,512 KB
testcase_14 AC 118 ms
106,296 KB
testcase_15 AC 108 ms
108,416 KB
testcase_16 AC 68 ms
70,912 KB
testcase_17 AC 88 ms
89,984 KB
testcase_18 AC 130 ms
106,752 KB
testcase_19 AC 63 ms
68,992 KB
testcase_20 AC 122 ms
117,760 KB
testcase_21 AC 118 ms
114,004 KB
testcase_22 AC 106 ms
109,316 KB
testcase_23 AC 85 ms
87,808 KB
testcase_24 AC 63 ms
71,808 KB
testcase_25 AC 119 ms
117,696 KB
testcase_26 AC 87 ms
94,080 KB
testcase_27 AC 59 ms
68,096 KB
testcase_28 AC 109 ms
110,324 KB
testcase_29 AC 111 ms
108,596 KB
testcase_30 AC 116 ms
111,052 KB
testcase_31 AC 60 ms
68,916 KB
testcase_32 AC 95 ms
93,064 KB
testcase_33 AC 91 ms
98,728 KB
testcase_34 AC 69 ms
80,512 KB
testcase_35 AC 42 ms
53,760 KB
testcase_36 AC 59 ms
70,912 KB
testcase_37 AC 90 ms
93,440 KB
testcase_38 AC 118 ms
116,096 KB
testcase_39 AC 95 ms
92,580 KB
testcase_40 AC 56 ms
64,640 KB
testcase_41 AC 85 ms
82,944 KB
testcase_42 AC 73 ms
73,728 KB
testcase_43 AC 38 ms
51,840 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