結果

問題 No.1741 Arrays and XOR Procedure
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-21 10:10:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,086 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 121,220 KB
最終ジャッジ日時 2023-08-16 14:15:04
合計ジャッジ時間 8,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
92,388 KB
testcase_01 AC 99 ms
92,204 KB
testcase_02 AC 97 ms
92,128 KB
testcase_03 AC 151 ms
121,148 KB
testcase_04 AC 97 ms
92,264 KB
testcase_05 AC 132 ms
120,912 KB
testcase_06 AC 148 ms
121,220 KB
testcase_07 AC 149 ms
121,180 KB
testcase_08 AC 130 ms
120,916 KB
testcase_09 AC 140 ms
117,568 KB
testcase_10 AC 140 ms
117,708 KB
testcase_11 AC 135 ms
112,152 KB
testcase_12 AC 128 ms
107,424 KB
testcase_13 AC 141 ms
117,548 KB
testcase_14 AC 130 ms
109,452 KB
testcase_15 AC 127 ms
114,420 KB
testcase_16 AC 108 ms
92,872 KB
testcase_17 WA -
testcase_18 AC 131 ms
109,560 KB
testcase_19 AC 103 ms
92,636 KB
testcase_20 WA -
testcase_21 AC 129 ms
114,380 KB
testcase_22 WA -
testcase_23 AC 110 ms
98,440 KB
testcase_24 AC 110 ms
93,052 KB
testcase_25 AC 137 ms
120,924 KB
testcase_26 WA -
testcase_27 AC 104 ms
92,832 KB
testcase_28 AC 127 ms
111,724 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 120 ms
102,592 KB
testcase_33 AC 131 ms
105,704 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 111 ms
93,308 KB
testcase_37 AC 114 ms
102,424 KB
testcase_38 AC 145 ms
120,900 KB
testcase_39 AC 114 ms
101,032 KB
testcase_40 AC 101 ms
92,640 KB
testcase_41 AC 107 ms
95,484 KB
testcase_42 WA -
testcase_43 AC 97 ms
92,124 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 i == 0 or i == n-1:
            x ^= b
        else:
            if (n-1)%2 == 0:
                continue
            else:
                x ^= b
    else:
        if i == 0 or i == n-1:
            o += 1
        else:
            if (n-1)%2 == 0:
                e += 1
            else:
                o += 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