結果

問題 No.866 レベルKの正方形
ユーザー vwxyzvwxyz
提出日時 2024-04-14 14:19:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 766 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 791,332 KB
最終ジャッジ日時 2024-04-14 14:19:26
合計ジャッジ時間 10,113 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
17,952 KB
testcase_01 AC 37 ms
10,880 KB
testcase_02 AC 37 ms
10,880 KB
testcase_03 AC 37 ms
10,880 KB
testcase_04 AC 36 ms
10,880 KB
testcase_05 AC 36 ms
10,880 KB
testcase_06 AC 37 ms
11,008 KB
testcase_07 AC 37 ms
10,880 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 h in range(H)] for a in range(26)]
for a in range(26):
    for h in range(H):
        for w in range(W):
            if A[h][w]==a:
                dp[a][h][w]=0
            if h:
                dp[a][h][w]=min(dp[a][h][w],dp[a][h-1][w]+1)
            if w:
                dp[a][h][w]=min(dp[a][h][w],dp[a][h][w-1]+1)
            if h and w:
                dp[a][h][w]=min(dp[a][h][w],dp[a][h-1][w-1]+1)
ans=0
for h in range(H):
    for w in range(W):
        idx=[dp[a][h][w] for a in range(26) if dp[a][h][w]<=min(h,w)]
        idx.sort()
        idx.append(min(h,w)+1)
        if len(idx)>K:
            ans+=idx[K]-idx[K-1]
print(ans)
0