結果
| 問題 |
No.2230 Good Omen of White Lotus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-25 17:46:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 768 bytes |
| コンパイル時間 | 260 ms |
| コンパイル使用メモリ | 82,208 KB |
| 実行使用メモリ | 844,476 KB |
| 最終ジャッジ日時 | 2024-09-13 13:52:35 |
| 合計ジャッジ時間 | 5,867 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 12 WA * 9 MLE * 1 -- * 22 |
ソースコード
H,W,N,P = map(int,input().split())
s = set()
for _ in range(N):
x,y = map(int,input().split())
s.add((x-1,y-1))
dp = [[0] * W for _ in range(H)]
memo = [[0] * W for _ in range(H)]
stack = [(0,0)]
while stack:
x,y = stack.pop()
for i,j in [(1,0),(0,1)]:
if x + i < H and y + j < W:
if memo[x + i][y + j] == 0:
memo[x + i][y + j] = 1
stack.append((x + i,y + j))
if (x + i,y + j) in s:
t = dp[x][y] + 1
else:
t = dp[x][y]
if t > dp[x + i][y + j]:
dp[x + i][y + j] = t
u = dp[-1][-1]
mod = 998244353
v = H + W - 3 - u
r = pow(P,mod-2,mod)
tmp = pow((1-r)%mod,v,mod)*pow((1-r * 2)%mod,u,mod)
ans = (1-tmp)%mod
print(ans)