結果

問題 No.1741 Arrays and XOR Procedure
ユーザー H3PO4H3PO4
提出日時 2021-11-12 22:32:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,054 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 101,376 KB
最終ジャッジ日時 2024-05-04 09:49:00
合計ジャッジ時間 5,891 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
61,824 KB
testcase_01 AC 46 ms
61,748 KB
testcase_02 AC 42 ms
61,824 KB
testcase_03 AC 107 ms
101,376 KB
testcase_04 AC 45 ms
61,312 KB
testcase_05 AC 102 ms
100,864 KB
testcase_06 AC 108 ms
101,236 KB
testcase_07 AC 112 ms
101,248 KB
testcase_08 AC 108 ms
100,964 KB
testcase_09 AC 103 ms
98,176 KB
testcase_10 AC 101 ms
98,688 KB
testcase_11 AC 99 ms
94,064 KB
testcase_12 AC 88 ms
90,488 KB
testcase_13 AC 102 ms
97,920 KB
testcase_14 AC 96 ms
91,776 KB
testcase_15 AC 99 ms
96,128 KB
testcase_16 AC 63 ms
75,008 KB
testcase_17 AC 82 ms
84,528 KB
testcase_18 AC 98 ms
92,032 KB
testcase_19 AC 59 ms
72,960 KB
testcase_20 AC 112 ms
101,248 KB
testcase_21 AC 105 ms
95,744 KB
testcase_22 AC 94 ms
93,968 KB
testcase_23 AC 73 ms
84,032 KB
testcase_24 AC 59 ms
76,672 KB
testcase_25 AC 104 ms
100,736 KB
testcase_26 AC 78 ms
86,656 KB
testcase_27 AC 58 ms
72,192 KB
testcase_28 AC 90 ms
93,824 KB
testcase_29 AC 97 ms
96,384 KB
testcase_30 AC 92 ms
94,028 KB
testcase_31 AC 55 ms
73,472 KB
testcase_32 AC 83 ms
86,656 KB
testcase_33 AC 85 ms
88,960 KB
testcase_34 AC 72 ms
82,048 KB
testcase_35 AC 49 ms
63,744 KB
testcase_36 AC 69 ms
79,616 KB
testcase_37 AC 84 ms
86,400 KB
testcase_38 AC 107 ms
100,608 KB
testcase_39 AC 85 ms
85,504 KB
testcase_40 AC 56 ms
69,120 KB
testcase_41 AC 71 ms
81,920 KB
testcase_42 AC 62 ms
74,624 KB
testcase_43 AC 45 ms
61,440 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