結果

問題 No.1741 Arrays and XOR Procedure
ユーザー H3PO4H3PO4
提出日時 2021-11-12 22:32:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,054 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 102,908 KB
最終ジャッジ日時 2023-08-17 02:37:39
合計ジャッジ時間 7,225 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
79,136 KB
testcase_01 AC 77 ms
79,160 KB
testcase_02 AC 77 ms
79,196 KB
testcase_03 AC 143 ms
102,908 KB
testcase_04 AC 80 ms
79,388 KB
testcase_05 AC 138 ms
102,232 KB
testcase_06 AC 144 ms
102,548 KB
testcase_07 AC 145 ms
102,548 KB
testcase_08 AC 137 ms
102,136 KB
testcase_09 AC 136 ms
99,492 KB
testcase_10 AC 136 ms
99,908 KB
testcase_11 AC 130 ms
94,980 KB
testcase_12 AC 120 ms
91,524 KB
testcase_13 AC 140 ms
99,144 KB
testcase_14 AC 137 ms
93,180 KB
testcase_15 AC 136 ms
97,520 KB
testcase_16 AC 97 ms
80,684 KB
testcase_17 AC 108 ms
85,900 KB
testcase_18 AC 126 ms
93,572 KB
testcase_19 AC 91 ms
79,876 KB
testcase_20 AC 143 ms
102,244 KB
testcase_21 AC 133 ms
96,816 KB
testcase_22 AC 124 ms
94,972 KB
testcase_23 AC 108 ms
85,448 KB
testcase_24 AC 94 ms
81,044 KB
testcase_25 AC 140 ms
102,128 KB
testcase_26 AC 110 ms
87,956 KB
testcase_27 AC 90 ms
79,972 KB
testcase_28 AC 124 ms
95,180 KB
testcase_29 AC 130 ms
97,476 KB
testcase_30 AC 126 ms
95,372 KB
testcase_31 AC 91 ms
80,028 KB
testcase_32 AC 111 ms
87,908 KB
testcase_33 AC 114 ms
90,364 KB
testcase_34 AC 100 ms
83,352 KB
testcase_35 AC 83 ms
79,436 KB
testcase_36 AC 95 ms
81,120 KB
testcase_37 AC 114 ms
87,768 KB
testcase_38 AC 140 ms
101,852 KB
testcase_39 AC 116 ms
86,744 KB
testcase_40 AC 89 ms
79,656 KB
testcase_41 AC 107 ms
83,104 KB
testcase_42 AC 97 ms
79,976 KB
testcase_43 AC 78 ms
79,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
B = map(int, input().split())
MOD = 998244353
MAX = 2 * 10 ** 5 + 10
# https://tjkendev.github.io/procon-library/python/math/factorial.html から拝借しています。
fact = [1] * (MAX + 1)
rfact = [1] * (MAX + 1)
r = 1
for i in range(1, MAX + 1):
    fact[i] = r = r * i % MOD
rfact[MAX] = r = pow(fact[MAX], MOD - 2, MOD)
for i in range(MAX, 0, -1):
    rfact[i - 1] = r = r * i % MOD


def comb(n, k, error=0):
    if not 0 <= k <= n:
        return error
    return fact[n] * rfact[k] * rfact[n - k] % MOD


def p2(x):
    res = 0
    while not x % 2:
        x //= 2
        res += 1
    return res


comb2 = [0] * N
for i in range(1, N):
    comb2[i] = comb2[i - 1] + p2(N - i) - p2(i)

cur = 0
ct_odd = 0
ct_even = 0
for b, c in zip(B, comb2):
    if b == -1:
        if c:
            ct_even += 1
        else:
            ct_odd += 1
        continue
    if not c:
        cur ^= b

ans = 0
for x in range(1 - cur, ct_odd + 1, 2):
    ans += comb(ct_odd, x)
    ans %= MOD
ans *= pow(2, ct_even, MOD)
ans %= MOD
print(ans)
0