結果

問題 No.1741 Arrays and XOR Procedure
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-21 10:22:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,404 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 120,920 KB
最終ジャッジ日時 2023-08-16 14:30:42
合計ジャッジ時間 9,570 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
91,608 KB
testcase_01 AC 98 ms
91,780 KB
testcase_02 AC 100 ms
91,968 KB
testcase_03 AC 386 ms
120,920 KB
testcase_04 AC 98 ms
92,052 KB
testcase_05 AC 132 ms
120,304 KB
testcase_06 AC 262 ms
120,912 KB
testcase_07 AC 259 ms
120,736 KB
testcase_08 AC 129 ms
120,576 KB
testcase_09 AC 206 ms
117,100 KB
testcase_10 AC 205 ms
117,408 KB
testcase_11 AC 183 ms
111,600 KB
testcase_12 AC 161 ms
106,796 KB
testcase_13 AC 198 ms
116,960 KB
testcase_14 AC 178 ms
109,216 KB
testcase_15 AC 191 ms
114,204 KB
testcase_16 AC 107 ms
92,456 KB
testcase_17 AC 131 ms
99,416 KB
testcase_18 AC 171 ms
109,180 KB
testcase_19 AC 106 ms
92,740 KB
testcase_20 AC 216 ms
120,544 KB
testcase_21 AC 188 ms
113,932 KB
testcase_22 AC 179 ms
111,324 KB
testcase_23 AC 132 ms
98,376 KB
testcase_24 AC 109 ms
92,644 KB
testcase_25 AC 218 ms
120,612 KB
testcase_26 AC 149 ms
102,020 KB
testcase_27 AC 109 ms
92,436 KB
testcase_28 AC 182 ms
111,696 KB
testcase_29 AC 197 ms
114,228 KB
testcase_30 AC 184 ms
111,488 KB
testcase_31 WA -
testcase_32 AC 145 ms
101,976 KB
testcase_33 AC 156 ms
105,348 KB
testcase_34 AC 121 ms
95,892 KB
testcase_35 WA -
testcase_36 AC 111 ms
93,072 KB
testcase_37 AC 142 ms
102,208 KB
testcase_38 AC 211 ms
120,440 KB
testcase_39 AC 151 ms
100,760 KB
testcase_40 AC 105 ms
92,772 KB
testcase_41 AC 128 ms
95,184 KB
testcase_42 AC 109 ms
92,600 KB
testcase_43 AC 95 ms
91,904 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

p = 2
C = [[0]*(p+1) for i in range(p+1)] #C[n][k] > nCk

for i in range(p+1):
    for j in range(i+1):
        if j == 0 or j == i:
            C[i][j] = 1
        else:
            C[i][j] = C[i-1][j-1]+C[i-1][j]

def cmb2(n, k, p):
    ret = 1
    while n > 0:
        ni = n%p
        ki = k%p
        ret *= C[ni][ki]
        ret %= p
        n //= p
        k //= p
    return ret

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 i == 0 or i == n-1:
            x ^= b
        else:
            if (n-1)%2 == 0:
                continue
            else:
                x ^= b
    else:
        if cmb2(n-1, i, 2)%2 == 1:
            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