結果

問題 No.1741 Arrays and XOR Procedure
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-21 10:33:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 121,376 KB
最終ジャッジ日時 2023-08-16 14:42:39
合計ジャッジ時間 7,444 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
91,932 KB
testcase_01 AC 97 ms
91,836 KB
testcase_02 AC 99 ms
92,176 KB
testcase_03 AC 139 ms
121,376 KB
testcase_04 AC 96 ms
92,000 KB
testcase_05 AC 130 ms
120,384 KB
testcase_06 AC 138 ms
120,972 KB
testcase_07 AC 140 ms
121,136 KB
testcase_08 AC 133 ms
120,816 KB
testcase_09 AC 131 ms
117,496 KB
testcase_10 AC 128 ms
117,484 KB
testcase_11 AC 125 ms
111,640 KB
testcase_12 AC 117 ms
107,068 KB
testcase_13 AC 129 ms
117,276 KB
testcase_14 AC 125 ms
109,280 KB
testcase_15 AC 129 ms
114,264 KB
testcase_16 AC 101 ms
92,708 KB
testcase_17 AC 108 ms
99,784 KB
testcase_18 AC 121 ms
109,400 KB
testcase_19 AC 100 ms
92,488 KB
testcase_20 AC 138 ms
120,796 KB
testcase_21 AC 128 ms
114,244 KB
testcase_22 AC 125 ms
111,580 KB
testcase_23 AC 112 ms
98,120 KB
testcase_24 AC 103 ms
92,560 KB
testcase_25 AC 137 ms
120,700 KB
testcase_26 AC 114 ms
102,292 KB
testcase_27 AC 101 ms
92,544 KB
testcase_28 AC 125 ms
111,696 KB
testcase_29 AC 132 ms
114,436 KB
testcase_30 AC 127 ms
111,848 KB
testcase_31 AC 101 ms
92,528 KB
testcase_32 AC 116 ms
102,224 KB
testcase_33 AC 119 ms
105,412 KB
testcase_34 AC 106 ms
96,100 KB
testcase_35 AC 98 ms
92,040 KB
testcase_36 AC 102 ms
92,856 KB
testcase_37 AC 115 ms
102,184 KB
testcase_38 AC 134 ms
120,708 KB
testcase_39 AC 124 ms
101,216 KB
testcase_40 AC 99 ms
92,624 KB
testcase_41 AC 108 ms
95,472 KB
testcase_42 AC 103 ms
92,836 KB
testcase_43 AC 96 ms
92,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 10**6
mod = 998244353
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def cmb1(n, r, mod):
    if r <0 or r > n:
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod

n = int(input())
B = list(map(int, input().split()))

x = 0
o = 0
e = 0
for i, b in enumerate(B):
    if b != -1:
        if ((n-1)&i) == i:
            x ^= b
    else:
        if ((n-1)&i) == i:
            o += 1
        else:
            e += 1

ans = 0
if x == 0:
    for k in range(o+1):
        if k%2 == 0:
            continue
        ans += cmb1(o, k, mod)*pow(2, e, mod)
        ans %= mod
else:
    for k in range(o+1):
        if k%2 == 1:
            continue
        ans += cmb1(o, k, mod)*pow(2, e, mod)
        ans %= mod
print(ans)
0