結果
問題 | No.1354 Sambo's Treasure |
ユーザー | titia |
提出日時 | 2021-09-01 23:30:50 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,213 bytes |
コンパイル時間 | 599 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 143,744 KB |
最終ジャッジ日時 | 2024-05-06 13:35:49 |
合計ジャッジ時間 | 14,308 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 106 ms
136,064 KB |
testcase_01 | RE | - |
testcase_02 | AC | 105 ms
136,064 KB |
testcase_03 | AC | 104 ms
135,424 KB |
testcase_04 | AC | 106 ms
135,680 KB |
testcase_05 | AC | 108 ms
136,192 KB |
testcase_06 | AC | 107 ms
136,064 KB |
testcase_07 | AC | 105 ms
135,680 KB |
testcase_08 | AC | 105 ms
135,808 KB |
testcase_09 | AC | 107 ms
135,424 KB |
testcase_10 | AC | 106 ms
136,064 KB |
testcase_11 | AC | 108 ms
135,680 KB |
testcase_12 | AC | 105 ms
135,552 KB |
testcase_13 | AC | 108 ms
135,936 KB |
testcase_14 | AC | 106 ms
135,936 KB |
testcase_15 | AC | 106 ms
135,552 KB |
testcase_16 | AC | 107 ms
135,936 KB |
testcase_17 | AC | 103 ms
135,552 KB |
testcase_18 | AC | 103 ms
136,064 KB |
testcase_19 | AC | 108 ms
135,424 KB |
testcase_20 | AC | 107 ms
135,808 KB |
testcase_21 | AC | 106 ms
135,680 KB |
testcase_22 | AC | 104 ms
135,296 KB |
testcase_23 | AC | 346 ms
131,424 KB |
testcase_24 | AC | 340 ms
131,164 KB |
testcase_25 | AC | 288 ms
131,240 KB |
testcase_26 | AC | 348 ms
131,940 KB |
testcase_27 | AC | 347 ms
132,188 KB |
testcase_28 | AC | 334 ms
131,544 KB |
testcase_29 | AC | 293 ms
130,532 KB |
testcase_30 | AC | 326 ms
131,088 KB |
testcase_31 | AC | 335 ms
131,680 KB |
testcase_32 | AC | 284 ms
130,876 KB |
testcase_33 | AC | 289 ms
131,224 KB |
testcase_34 | AC | 370 ms
132,112 KB |
testcase_35 | AC | 277 ms
131,296 KB |
testcase_36 | AC | 323 ms
131,468 KB |
testcase_37 | AC | 330 ms
131,576 KB |
testcase_38 | AC | 351 ms
132,068 KB |
testcase_39 | AC | 345 ms
131,416 KB |
testcase_40 | AC | 350 ms
131,040 KB |
testcase_41 | AC | 344 ms
131,680 KB |
testcase_42 | AC | 334 ms
131,164 KB |
testcase_43 | AC | 121 ms
140,672 KB |
testcase_44 | AC | 120 ms
140,928 KB |
testcase_45 | AC | 121 ms
140,928 KB |
testcase_46 | AC | 119 ms
141,440 KB |
testcase_47 | AC | 119 ms
140,928 KB |
testcase_48 | AC | 123 ms
141,184 KB |
testcase_49 | AC | 121 ms
140,672 KB |
testcase_50 | AC | 120 ms
140,672 KB |
testcase_51 | AC | 121 ms
140,800 KB |
testcase_52 | AC | 120 ms
140,800 KB |
testcase_53 | AC | 119 ms
141,184 KB |
testcase_54 | AC | 118 ms
140,672 KB |
testcase_55 | AC | 121 ms
140,672 KB |
testcase_56 | AC | 117 ms
140,800 KB |
testcase_57 | AC | 121 ms
140,928 KB |
testcase_58 | AC | 120 ms
140,800 KB |
testcase_59 | AC | 122 ms
140,800 KB |
testcase_60 | AC | 118 ms
141,312 KB |
testcase_61 | AC | 119 ms
141,056 KB |
testcase_62 | AC | 122 ms
141,184 KB |
testcase_63 | RE | - |
ソースコード
import sys input = sys.stdin.readline from operator import itemgetter N,M,L,K=map(int,input().split()) C=[tuple(map(int,input().split())) for i in range(M)] T=[tuple(map(int,input().split())) for i in range(L)] mod=998244353 C.append((N,N)) FACT=[1] for i in range(1,5*10**5+1): FACT.append(FACT[-1]*i%mod) FACT_INV=[pow(FACT[-1],mod-2,mod)] for i in range(5*10**5,0,-1): FACT_INV.append(FACT_INV[-1]*i%mod) FACT_INV.reverse() def Combi(a,b): if 0<=b<=a: return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod else: return 0 C.sort() T.sort() for i in range(1,M+1): if C[i][1]<C[i-1][1]: print(0) exit() T2=[[] for i in range(M+1)] ind=0 C.append((0,0)) for i in range(M+1): x,y=C[i] while ind<L and (T[ind][0]<x or (T[ind][0]==x and T[ind][1]<=y)): if C[i-1][1]<=T[ind][1]<=C[i][1]: T2[i].append(T[ind]) ind+=1 NOW=[1] for i in range(M+1): sx,sy=C[i-1] gx,gy=C[i] LIST=[(sx,sy)]+T2[i]+[(gx,gy)] DP=[[] for i in range(len(LIST))] DP[0]=[1] for j in range(1,len(LIST)): tx,ty=LIST[j] NDP=[0]*(j+1) for k in range(j-1,-1,-1): x,y=LIST[k] COM=Combi((tx-x)+(ty-y),(tx-x)) if j!=len(LIST)-1: for l in range(k+1): NDP[l+1]+=COM*DP[k][l]%mod NDP[l+1]%=mod else: for l in range(k+1): NDP[l]+=COM*DP[k][l]%mod NDP[l]%=mod if j!=len(LIST)-1: for l in range(1,j): NDP[l]-=NDP[l+1] NDP[l]%=mod else: for l in range(j): NDP[l]-=NDP[l+1] NDP[l]%=mod DP[j]=NDP dp=DP[-1] while dp[-1]==0: dp.pop() NEXT=[0]*(len(dp)+len(NOW)) for i in range(len(dp)): for j in range(len(NOW)): NEXT[i+j]+=dp[i]*NOW[j]%mod NEXT[i+j]%=mod NOW=NEXT while NOW[-1]==0: NOW.pop() ANS=0 for i in range(K+1): ANS+=NOW[i] ANS%=mod print(ANS)