結果
| 問題 |
No.2230 Good Omen of White Lotus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-25 17:50:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 739 bytes |
| コンパイル時間 | 161 ms |
| コンパイル使用メモリ | 82,372 KB |
| 実行使用メモリ | 844,860 KB |
| 最終ジャッジ日時 | 2024-09-13 13:55:42 |
| 合計ジャッジ時間 | 5,033 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 MLE * 1 -- * 22 |
ソースコード
H,W,N,P = map(int,input().split())
dat = [[0] * W for _ in range(H)]
for _ in range(N):
x,y = map(int,input().split())
dat[x-1][y-1] = 1
dp = [[-1] * W for _ in range(H)]
dp[0][0] = 0
#memo = [[0] * W for _ in range(H)]
from collections import deque
stack = deque([(0,0)])
while stack:
x,y = stack.popleft()
for i,j in [(1,0),(0,1)]:
if x + i < H and y + j < W:
if dp[x + i][y + j] == -1:
stack.append((x + i,y + j))
t = dp[x][y] + dat[x + i][y + j]
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)