結果

問題 No.1741 Arrays and XOR Procedure
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-11-12 22:42:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 107,264 KB
最終ジャッジ日時 2024-05-04 10:14:13
合計ジャッジ時間 4,559 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,840 KB
testcase_01 AC 32 ms
51,840 KB
testcase_02 AC 33 ms
52,480 KB
testcase_03 AC 86 ms
106,880 KB
testcase_04 AC 33 ms
52,224 KB
testcase_05 AC 91 ms
106,496 KB
testcase_06 AC 91 ms
107,264 KB
testcase_07 AC 90 ms
106,624 KB
testcase_08 AC 83 ms
106,624 KB
testcase_09 AC 87 ms
102,912 KB
testcase_10 AC 89 ms
102,912 KB
testcase_11 AC 88 ms
101,212 KB
testcase_12 AC 80 ms
94,592 KB
testcase_13 AC 88 ms
102,784 KB
testcase_14 AC 81 ms
98,048 KB
testcase_15 AC 83 ms
99,840 KB
testcase_16 AC 54 ms
69,760 KB
testcase_17 AC 68 ms
85,248 KB
testcase_18 AC 86 ms
98,176 KB
testcase_19 AC 52 ms
68,096 KB
testcase_20 AC 94 ms
106,496 KB
testcase_21 AC 84 ms
102,784 KB
testcase_22 AC 83 ms
98,816 KB
testcase_23 AC 69 ms
84,352 KB
testcase_24 AC 52 ms
69,632 KB
testcase_25 AC 92 ms
106,624 KB
testcase_26 AC 70 ms
87,808 KB
testcase_27 AC 52 ms
67,584 KB
testcase_28 AC 85 ms
99,072 KB
testcase_29 AC 85 ms
99,968 KB
testcase_30 AC 89 ms
101,248 KB
testcase_31 AC 50 ms
67,328 KB
testcase_32 AC 68 ms
88,448 KB
testcase_33 AC 73 ms
91,264 KB
testcase_34 AC 56 ms
76,544 KB
testcase_35 AC 34 ms
53,120 KB
testcase_36 AC 54 ms
70,528 KB
testcase_37 AC 73 ms
88,448 KB
testcase_38 AC 92 ms
106,368 KB
testcase_39 AC 67 ms
86,528 KB
testcase_40 AC 45 ms
64,768 KB
testcase_41 AC 57 ms
76,160 KB
testcase_42 AC 50 ms
68,096 KB
testcase_43 AC 33 ms
51,840 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