結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
92,260 KB
testcase_01 AC 100 ms
92,128 KB
testcase_02 AC 98 ms
92,056 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 131 ms
120,624 KB
testcase_06 AC 146 ms
121,016 KB
testcase_07 WA -
testcase_08 AC 128 ms
120,828 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 131 ms
112,120 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 128 ms
114,688 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 125 ms
114,516 KB
testcase_22 WA -
testcase_23 AC 109 ms
98,616 KB
testcase_24 WA -
testcase_25 AC 136 ms
120,944 KB
testcase_26 WA -
testcase_27 AC 104 ms
92,708 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 102 ms
92,768 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 108 ms
93,328 KB
testcase_37 AC 114 ms
102,344 KB
testcase_38 AC 142 ms
121,172 KB
testcase_39 AC 112 ms
101,016 KB
testcase_40 AC 102 ms
92,776 KB
testcase_41 AC 107 ms
95,600 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

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:
        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:
    ans = pow(2, o, mod)-1
    ans *= pow(2, e, mod)
    ans %= mod
else:
    for k in range(o+1):
        if k%2 == 0:
            continue
        ans += cmb1(o, k, mod)*pow(2, e, mod)
        ans %= mod
print(ans)
0