結果

問題 No.2230 Good Omen of White Lotus
ユーザー titiatitia
提出日時 2023-03-19 05:00:49
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 1,116 ms / 2,000 ms
コード長 1,175 bytes
コンパイル時間 210 ms
使用メモリ 111,688 KB
最終ジャッジ日時 2023-03-19 05:01:13
合計ジャッジ時間 20,685 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 60 ms
79,596 KB
testcase_01 AC 60 ms
79,672 KB
testcase_02 AC 61 ms
79,868 KB
testcase_03 AC 62 ms
79,656 KB
testcase_04 AC 60 ms
79,976 KB
testcase_05 AC 61 ms
79,900 KB
testcase_06 AC 63 ms
79,876 KB
testcase_07 AC 65 ms
79,928 KB
testcase_08 AC 65 ms
79,604 KB
testcase_09 AC 61 ms
79,708 KB
testcase_10 AC 64 ms
79,976 KB
testcase_11 AC 61 ms
79,916 KB
testcase_12 AC 62 ms
79,704 KB
testcase_13 AC 72 ms
84,428 KB
testcase_14 AC 423 ms
100,540 KB
testcase_15 AC 81 ms
84,712 KB
testcase_16 AC 404 ms
107,944 KB
testcase_17 AC 418 ms
107,836 KB
testcase_18 AC 440 ms
108,180 KB
testcase_19 AC 418 ms
108,156 KB
testcase_20 AC 171 ms
88,644 KB
testcase_21 AC 167 ms
87,480 KB
testcase_22 AC 153 ms
89,384 KB
testcase_23 AC 174 ms
89,292 KB
testcase_24 AC 62 ms
79,940 KB
testcase_25 AC 60 ms
79,876 KB
testcase_26 AC 62 ms
79,924 KB
testcase_27 AC 369 ms
111,688 KB
testcase_28 AC 397 ms
107,856 KB
testcase_29 AC 451 ms
108,000 KB
testcase_30 AC 432 ms
108,440 KB
testcase_31 AC 462 ms
108,004 KB
testcase_32 AC 451 ms
107,832 KB
testcase_33 AC 1,037 ms
109,116 KB
testcase_34 AC 1,070 ms
109,224 KB
testcase_35 AC 1,089 ms
109,280 KB
testcase_36 AC 1,116 ms
109,188 KB
testcase_37 AC 1,062 ms
109,268 KB
testcase_38 AC 1,065 ms
109,184 KB
testcase_39 AC 1,091 ms
109,048 KB
testcase_40 AC 380 ms
93,616 KB
testcase_41 AC 387 ms
93,840 KB
testcase_42 AC 775 ms
102,332 KB
testcase_43 AC 154 ms
87,832 KB
testcase_44 AC 995 ms
106,380 KB
testcase_45 AC 404 ms
94,268 KB
testcase_46 AC 640 ms
98,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353

H,W,N,Px=map(int,input().split())
P=[list(map(int,input().split())) for i in range(N)]

# Segment tree(1-indexed,再帰を使わないもの)

def seg_function(x,y): # Segment treeで扱うfunction
    return max(x,y)

LEN=202000
seg_el=1<<(LEN.bit_length()) # Segment treeの台の要素数
SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化


def update(n,x,seg_el): # A[n]をxへ更新
    i=n+seg_el
    SEG[i]=x
    i>>=1 # 子ノードへ
    
    while i!=0:
        SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r): # 区間[l,r)に関するseg_functionを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=0

    while L<R:
        if L & 1:
            ANS=seg_function(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=seg_function(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

P.sort()
for x,y in P:
    MAX=getvalues(0,y+1)
    update(y,MAX+1,seg_el)
    
ANS=getvalues(0,LEN)
idou=H-1+W-2
nokori=idou-ANS

# (1-2/P)**ANS*(1-1/P)**nokori

INV=pow(Px,mod-2,mod)

print((1-pow((1-2*INV),ANS,mod)*pow((1-INV),nokori,mod))%mod)
0