結果
問題 |
No.2230 Good Omen of White Lotus
|
ユーザー |
|
提出日時 | 2023-02-25 17:48:47 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 784 bytes |
コンパイル時間 | 339 ms |
コンパイル使用メモリ | 81,892 KB |
実行使用メモリ | 844,480 KB |
最終ジャッジ日時 | 2024-09-13 13:54:22 |
合計ジャッジ時間 | 6,233 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 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 = [[-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)) 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)