結果
問題 | No.2230 Good Omen of White Lotus |
ユーザー | mkawa2 |
提出日時 | 2023-02-24 22:52:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 977 ms / 2,000 ms |
コード長 | 1,452 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 87,296 KB |
実行使用メモリ | 101,828 KB |
最終ジャッジ日時 | 2023-10-11 06:42:17 |
合計ジャッジ時間 | 18,503 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
71,212 KB |
testcase_01 | AC | 74 ms
71,296 KB |
testcase_02 | AC | 75 ms
71,208 KB |
testcase_03 | AC | 73 ms
71,208 KB |
testcase_04 | AC | 74 ms
71,556 KB |
testcase_05 | AC | 73 ms
71,244 KB |
testcase_06 | AC | 74 ms
71,372 KB |
testcase_07 | AC | 74 ms
71,132 KB |
testcase_08 | AC | 73 ms
71,500 KB |
testcase_09 | AC | 75 ms
71,380 KB |
testcase_10 | AC | 75 ms
71,276 KB |
testcase_11 | AC | 75 ms
71,236 KB |
testcase_12 | AC | 76 ms
71,304 KB |
testcase_13 | AC | 77 ms
71,292 KB |
testcase_14 | AC | 299 ms
90,468 KB |
testcase_15 | AC | 86 ms
75,864 KB |
testcase_16 | AC | 287 ms
98,328 KB |
testcase_17 | AC | 287 ms
98,348 KB |
testcase_18 | AC | 285 ms
98,452 KB |
testcase_19 | AC | 291 ms
98,180 KB |
testcase_20 | AC | 115 ms
78,952 KB |
testcase_21 | AC | 104 ms
77,852 KB |
testcase_22 | AC | 121 ms
79,328 KB |
testcase_23 | AC | 123 ms
79,528 KB |
testcase_24 | AC | 80 ms
76,940 KB |
testcase_25 | AC | 80 ms
77,112 KB |
testcase_26 | AC | 78 ms
77,156 KB |
testcase_27 | AC | 278 ms
99,864 KB |
testcase_28 | AC | 274 ms
99,768 KB |
testcase_29 | AC | 287 ms
99,900 KB |
testcase_30 | AC | 299 ms
99,744 KB |
testcase_31 | AC | 295 ms
99,756 KB |
testcase_32 | AC | 286 ms
99,880 KB |
testcase_33 | AC | 968 ms
101,828 KB |
testcase_34 | AC | 963 ms
101,304 KB |
testcase_35 | AC | 972 ms
101,736 KB |
testcase_36 | AC | 967 ms
101,284 KB |
testcase_37 | AC | 977 ms
101,748 KB |
testcase_38 | AC | 961 ms
101,216 KB |
testcase_39 | AC | 956 ms
101,428 KB |
testcase_40 | AC | 322 ms
85,776 KB |
testcase_41 | AC | 322 ms
84,964 KB |
testcase_42 | AC | 644 ms
93,240 KB |
testcase_43 | AC | 126 ms
79,776 KB |
testcase_44 | AC | 845 ms
98,268 KB |
testcase_45 | AC | 344 ms
85,764 KB |
testcase_46 | AC | 530 ms
90,792 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = (1 << 31)-1 # md = 10**9+7 md = 998244353 class Bit: def __init__(self, op, e, n): self.op = op self.e = e self.n = n+1 self.table = [e() for _ in range(self.n)] def update(self, i, x): i += 1 while i < self.n: self.table[i] = self.op(self.table[i], x) i += i & -i # [0,i] def prod(self, i): i += 1 res = self.e() while i > 0: res = self.op(res, self.table[i]) i -= i & -i return res h, w, n, p = LI() xy = LLI1(n) xy.sort() bit = Bit(max, int, w) for x, y in xy: now = bit.prod(y)+1 bit.update(y, now) c = bit.prod(w-1) m = h+w-3 p = pow(p, md-2, md) ans = 1-pow(1-p, m-c, md)*pow(1-2*p, c, md)%md print(ans%md)