結果
| 問題 |
No.2653 [Cherry 6th Tune] Re: start! (Make it Zero!)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-23 23:20:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,503 bytes |
| コンパイル時間 | 284 ms |
| コンパイル使用メモリ | 82,528 KB |
| 実行使用メモリ | 107,548 KB |
| 最終ジャッジ日時 | 2024-09-29 08:52:03 |
| 合計ジャッジ時間 | 11,246 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 71 |
ソースコード
import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes")
no = lambda :print("no");No = lambda :print("No")
#######################################################################
mod = 998244353
for _ in range(ni()):
n, m = na()
x = na()
dpc = [1, 0]
dps = [0, 0]
s = 0
ans = 0
for i in range(n):
ndps = [0, 0]
if x[i] != -1:
s += x[i]
s %= m
if s == 0 and x[i] == 0:
pass
elif s == x[i]:
ndps[0] = dps[0]
ndps[1] = dpc[1] + dpc[1]
ndps[1] %= mod
else:
ndps[0] = dpc[0] + dps[0]
ndps[1] = dpc[1] + dps[1]
ndps[0] %= mod
ndps[1] %= mod
else:
if s == 0:
ndps[0] = dpc[1] * (m-1) + dps[0] + dps[1] * (m-1)
ndps[1] = dpc[1] * (m-1) + dps[0] + dps[1] * (m-1)
else:
ndps[0] = dpc[0] + dpc[1] * (m-2) + dps[0] + dps[1] * (m-1)
ndps[1] = dpc[0] + dpc[1] * (m-2) + dps[0] + dps[1] * (m-1)
ndps[0] %= mod
ndps[1] %= mod
dpc = [dpc[0] + dpc[1] * (m-1), dpc[0] + dpc[1] * (m-1)]
dpc[0] %= mod
dpc[1] %= mod
dps = ndps
if s == 0:
print(dps[0])
else:
print(dps[1])