結果
| 問題 | No.866 レベルKの正方形 |
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-04-14 14:23:50 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 732 bytes |
| 記録 | |
| コンパイル時間 | 211 ms |
| コンパイル使用メモリ | 84,864 KB |
| 実行使用メモリ | 311,252 KB |
| 最終ジャッジ日時 | 2026-04-19 16:11:42 |
| 合計ジャッジ時間 | 9,241 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 8 TLE * 2 -- * 12 |
ソースコード
H,W,K=map(int,input().split())
A=[[ord(a)-97 for a in input()] for h in range(H)]
inf=1<<30
dp=[[inf for w in range(W)] for a in range(26)]
ans=0
for h in range(H):
prev=dp
dp=[[inf for w in range(W)] for a in range(26)]
for w in range(W):
for a in range(26):
if A[h][w]==a:
dp[a][w]=0
if h:
dp[a][w]=min(dp[a][w],prev[a][w]+1)
if w:
dp[a][w]=min(dp[a][w],dp[a][w-1]+1)
if h and w:
dp[a][w]=min(dp[a][w],prev[a][w-1]+1)
idx=[dp[a][w] for a in range(26) if dp[a][w]<=min(h,w)]
idx.sort()
idx.append(min(h,w)+1)
if len(idx)>K:
ans+=idx[K]-idx[K-1]
print(ans)
vwxyz