結果
問題 | No.2230 Good Omen of White Lotus |
ユーザー |
![]() |
提出日時 | 2023-03-19 05:00:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 897 ms / 2,000 ms |
コード長 | 1,175 bytes |
コンパイル時間 | 243 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 105,216 KB |
最終ジャッジ日時 | 2024-09-18 13:41:25 |
合計ジャッジ時間 | 14,895 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 |
ソースコード
mod=998244353H,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で扱うfunctionreturn max(x,y)LEN=202000seg_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_elSEG[i]=xi>>=1 # 子ノードへwhile i!=0:SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])i>>=1def getvalues(l,r): # 区間[l,r)に関するseg_functionを調べるL=l+seg_elR=r+seg_elANS=0while L<R:if L & 1:ANS=seg_function(ANS , SEG[L])L+=1if R & 1:R-=1ANS=seg_function(ANS , SEG[R])L>>=1R>>=1return ANSP.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-2nokori=idou-ANS# (1-2/P)**ANS*(1-1/P)**nokoriINV=pow(Px,mod-2,mod)print((1-pow((1-2*INV),ANS,mod)*pow((1-INV),nokori,mod))%mod)