結果
| 問題 |
No.2230 Good Omen of White Lotus
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-26 15:59:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 916 ms / 2,000 ms |
| コード長 | 907 bytes |
| コンパイル時間 | 338 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 109,408 KB |
| 最終ジャッジ日時 | 2025-03-26 16:00:19 |
| 合計ジャッジ時間 | 15,840 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
ソースコード
import bisect
H, W, N, P = map(int, input().split())
good = []
for _ in range(N):
x, y = map(int, input().split())
good.append((x, y))
# Sort good cells by x ascending, then y ascending
good.sort(key=lambda x: (x[0], x[1]))
# Extract y-coordinates and compute the length of the longest non-decreasing subsequence
ys = [y for x, y in good]
tails = []
for num in ys:
idx = bisect.bisect_right(tails, num)
if idx == len(tails):
tails.append(num)
else:
tails[idx] = num
k = len(tails)
total = H + W - 3
mod = 998244353
if total < k:
k = total # This should not happen as per problem constraints
term1 = pow(P - 2, k, mod)
term2 = pow(P - 1, total - k, mod)
numerator = (term1 * term2) % mod
denominator = pow(P, total, mod)
denominator_inv = pow(denominator, mod - 2, mod)
product = (numerator * denominator_inv) % mod
result = (1 - product) % mod
print(result)
lam6er