結果

問題 No.1741 Arrays and XOR Procedure
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-11-12 22:42:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 107,880 KB
最終ジャッジ日時 2023-08-17 03:00:27
合計ジャッジ時間 7,254 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,456 KB
testcase_01 AC 76 ms
71,452 KB
testcase_02 AC 70 ms
71,384 KB
testcase_03 AC 129 ms
106,580 KB
testcase_04 AC 69 ms
71,532 KB
testcase_05 AC 125 ms
107,672 KB
testcase_06 AC 135 ms
107,880 KB
testcase_07 AC 134 ms
107,524 KB
testcase_08 AC 128 ms
107,592 KB
testcase_09 AC 130 ms
104,112 KB
testcase_10 AC 129 ms
104,520 KB
testcase_11 AC 130 ms
102,320 KB
testcase_12 AC 118 ms
95,780 KB
testcase_13 AC 131 ms
103,840 KB
testcase_14 AC 126 ms
99,092 KB
testcase_15 AC 127 ms
101,156 KB
testcase_16 AC 94 ms
77,376 KB
testcase_17 AC 110 ms
87,160 KB
testcase_18 AC 132 ms
99,676 KB
testcase_19 AC 96 ms
77,364 KB
testcase_20 AC 138 ms
107,784 KB
testcase_21 AC 133 ms
104,320 KB
testcase_22 AC 129 ms
100,376 KB
testcase_23 AC 110 ms
85,784 KB
testcase_24 AC 96 ms
76,904 KB
testcase_25 AC 137 ms
107,640 KB
testcase_26 AC 112 ms
89,548 KB
testcase_27 AC 94 ms
77,480 KB
testcase_28 AC 129 ms
100,228 KB
testcase_29 AC 129 ms
101,032 KB
testcase_30 AC 131 ms
102,488 KB
testcase_31 AC 91 ms
76,820 KB
testcase_32 AC 116 ms
89,996 KB
testcase_33 AC 117 ms
92,920 KB
testcase_34 AC 104 ms
82,004 KB
testcase_35 AC 76 ms
71,368 KB
testcase_36 AC 96 ms
77,792 KB
testcase_37 AC 113 ms
89,708 KB
testcase_38 AC 138 ms
107,584 KB
testcase_39 AC 111 ms
88,088 KB
testcase_40 AC 86 ms
76,956 KB
testcase_41 AC 99 ms
81,476 KB
testcase_42 AC 95 ms
77,528 KB
testcase_43 AC 73 ms
71,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

A1+A3 , A2+A4 , A3+A

"""

import sys
from sys import stdin


def nCrB(n,r):

    binum = bi[n] - bi[r] - bi[n-r]
    if binum == 0:
        return 1
    else:
        return 0

mod = 998244353

N = int(stdin.readline())

bi = [0] * (N+1)
for i in range(1,30):
    x = 2**i
    for j in range(x,N+1,x):
        bi[j] += 1
for i in range(N):
    bi[i+1] += bi[i]

B = list(map(int,stdin.readline().split()))

C = [nCrB(N-1 , i) for i in range(N)]

dp = [1,0]

for i in range(N):

    ndp = [0,0]
    if B[i] == 0 or B[i] == -1:
        ndp[0] += dp[0]
        ndp[1] += dp[1]

    if B[i] == 1 or B[i] == -1:
        ndp[0 ^ C[i]] += dp[0]
        ndp[1 ^ C[i]] += dp[1]

    ndp[0] %= mod
    ndp[1] %= mod

    dp = ndp

print (dp[1] % mod)
0