結果
問題 | No.1388 Less than K |
ユーザー | vwxyz |
提出日時 | 2023-11-19 02:24:15 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,356 bytes |
コンパイル時間 | 418 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 92,188 KB |
最終ジャッジ日時 | 2024-09-26 06:08:30 |
合計ジャッジ時間 | 45,705 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,352 KB |
testcase_01 | AC | 40 ms
52,224 KB |
testcase_02 | AC | 47 ms
60,032 KB |
testcase_03 | AC | 40 ms
52,352 KB |
testcase_04 | AC | 54 ms
63,360 KB |
testcase_05 | AC | 87 ms
76,544 KB |
testcase_06 | AC | 78 ms
72,960 KB |
testcase_07 | AC | 47 ms
60,032 KB |
testcase_08 | AC | 103 ms
76,672 KB |
testcase_09 | AC | 69 ms
70,784 KB |
testcase_10 | AC | 67 ms
69,888 KB |
testcase_11 | AC | 64 ms
68,608 KB |
testcase_12 | AC | 102 ms
77,184 KB |
testcase_13 | AC | 122 ms
77,652 KB |
testcase_14 | AC | 151 ms
77,952 KB |
testcase_15 | AC | 301 ms
79,744 KB |
testcase_16 | AC | 397 ms
80,512 KB |
testcase_17 | AC | 597 ms
82,048 KB |
testcase_18 | AC | 957 ms
84,864 KB |
testcase_19 | AC | 1,367 ms
87,040 KB |
testcase_20 | AC | 1,457 ms
87,808 KB |
testcase_21 | AC | 130 ms
87,808 KB |
testcase_22 | AC | 74 ms
73,984 KB |
testcase_23 | AC | 82 ms
77,184 KB |
testcase_24 | AC | 105 ms
82,432 KB |
testcase_25 | AC | 115 ms
83,584 KB |
testcase_26 | AC | 102 ms
84,352 KB |
testcase_27 | AC | 86 ms
79,744 KB |
testcase_28 | AC | 67 ms
71,936 KB |
testcase_29 | AC | 68 ms
71,168 KB |
testcase_30 | AC | 55 ms
63,616 KB |
testcase_31 | AC | 59 ms
66,432 KB |
testcase_32 | AC | 49 ms
60,032 KB |
testcase_33 | AC | 73 ms
75,264 KB |
testcase_34 | AC | 74 ms
75,008 KB |
testcase_35 | AC | 70 ms
74,240 KB |
testcase_36 | AC | 88 ms
82,560 KB |
testcase_37 | AC | 76 ms
76,928 KB |
testcase_38 | AC | 157 ms
88,268 KB |
testcase_39 | AC | 107 ms
86,120 KB |
testcase_40 | AC | 130 ms
85,248 KB |
testcase_41 | AC | 253 ms
91,648 KB |
testcase_42 | AC | 102 ms
87,920 KB |
testcase_43 | AC | 721 ms
91,648 KB |
testcase_44 | AC | 2,230 ms
91,520 KB |
testcase_45 | AC | 871 ms
91,364 KB |
testcase_46 | AC | 1,115 ms
89,472 KB |
testcase_47 | AC | 2,835 ms
91,276 KB |
testcase_48 | AC | 2,478 ms
91,756 KB |
testcase_49 | TLE | - |
testcase_50 | AC | 2,849 ms
91,520 KB |
testcase_51 | AC | 939 ms
91,136 KB |
testcase_52 | AC | 800 ms
91,520 KB |
testcase_53 | AC | 369 ms
91,904 KB |
testcase_54 | AC | 209 ms
91,520 KB |
testcase_55 | AC | 84 ms
91,264 KB |
testcase_56 | AC | 621 ms
91,904 KB |
testcase_57 | AC | 1,663 ms
91,904 KB |
testcase_58 | AC | 2,948 ms
92,032 KB |
testcase_59 | AC | 975 ms
91,608 KB |
testcase_60 | AC | 786 ms
91,792 KB |
testcase_61 | AC | 98 ms
90,112 KB |
testcase_62 | AC | 78 ms
77,824 KB |
testcase_63 | AC | 101 ms
91,776 KB |
testcase_64 | AC | 128 ms
91,904 KB |
testcase_65 | AC | 213 ms
91,904 KB |
testcase_66 | AC | 374 ms
92,032 KB |
testcase_67 | AC | 369 ms
91,772 KB |
testcase_68 | AC | 1,196 ms
91,904 KB |
testcase_69 | AC | 1,387 ms
92,032 KB |
testcase_70 | AC | 2,283 ms
92,188 KB |
testcase_71 | AC | 1,158 ms
89,600 KB |
testcase_72 | AC | 113 ms
92,032 KB |
testcase_73 | AC | 100 ms
90,496 KB |
testcase_74 | AC | 94 ms
85,888 KB |
testcase_75 | AC | 87 ms
80,512 KB |
testcase_76 | AC | 83 ms
80,512 KB |
ソースコード
import sys readline=sys.stdin.readline H,W,K=map(int,readline().split()) H-=1;W-=1 K//=2 mod=998244353 fact=[1]+[i for i in range(1,H+W+1)] for i in range(1,H+W+1): fact[i]*=fact[i-1] fact[i]%=mod fact_inve=[i for i in range(1,H+W+1)]+[pow(fact[H+W],mod-2,mod)] for i in range(H+W-1,-1,-1): fact_inve[i]*=fact_inve[i+1] fact_inve[i]%=mod N=min(H,W) ans=0 if K<=300: for h in range(N+1): if h: prev=dp dp=[0]*(2*K+1) else: dp=[0]*(2*K+1) dp[K]=1 for w in range(max(h-K,0),min(h+K,N)+1): if h and abs((h-1)-w)<=K: dp[w-h+K]+=prev[w-(h-1)+K] if w and abs(h-(w-1))<=K: dp[w-h+K]+=dp[(w-1)-h+K] dp[w-h+K]%=mod ans+=fact[H+W]*fact_inve[H-h]%mod*fact_inve[W-h]%mod*fact_inve[2*h]%mod*dp[K]%mod ans%=mod else: for cnt in range(N+1): s=fact[2*cnt]*fact_inve[cnt]%mod*fact_inve[cnt]%mod for i in range(1,cnt//(K+1)+1): if i%2: s-=2*fact[2*cnt]*fact_inve[cnt-(K+1)*i]%mod*fact_inve[cnt+(K+1)*i]%mod else: s+=2*fact[2*cnt]*fact_inve[cnt-(K+1)*i]%mod*fact_inve[cnt+(K+1)*i]%mod s%=mod ans+=fact[H+W]*fact_inve[H-cnt]%mod*fact_inve[W-cnt]%mod*fact_inve[2*cnt]%mod*s%mod ans%=mod print(ans)