結果

問題 No.866 レベルKの正方形
ユーザー convexineqconvexineq
提出日時 2021-04-05 10:50:36
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 652 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 117,072 KB
最終ジャッジ日時 2023-08-28 23:10:59
合計ジャッジ時間 63,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,608 KB
testcase_01 AC 74 ms
76,160 KB
testcase_02 AC 75 ms
76,180 KB
testcase_03 AC 75 ms
76,172 KB
testcase_04 AC 75 ms
76,224 KB
testcase_05 AC 82 ms
76,256 KB
testcase_06 AC 73 ms
76,444 KB
testcase_07 AC 74 ms
76,252 KB
testcase_08 AC 5,809 ms
112,380 KB
testcase_09 AC 5,616 ms
112,540 KB
testcase_10 AC 4,955 ms
112,524 KB
testcase_11 TLE -
testcase_12 AC 5,310 ms
112,520 KB
testcase_13 AC 5,882 ms
112,208 KB
testcase_14 RE -
testcase_15 AC 5,472 ms
112,168 KB
testcase_16 AC 5,693 ms
112,512 KB
testcase_17 AC 5,518 ms
112,672 KB
testcase_18 AC 5,383 ms
112,364 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 2,894 ms
111,904 KB
testcase_22 AC 68 ms
71,356 KB
testcase_23 AC 68 ms
71,392 KB
testcase_24 AC 89 ms
76,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def clear(lst):
    for r in lst:
        for j in range(S):
            r[j] = 0

def a2i(x): return ord(x) - 97

def score(lst,i,j):
    lst = sorted(lst)
    if K != 26: return lst[K] - lst[K-1]
    else: return min(i,j) - lst[K]

h,w,K = map(int,input().split())
b = [list(map(a2i,input())) for _ in range(h)]
S = 26
dp = [[0]*S for _ in range(w)]
ndp = [[0]*S for _ in range(w)]
ans = 0
for i in range(h):
    clear(ndp)
    for j in range(w):
        for k in range(S):
            ndp[j][k] = min(ndp[j-1][k],dp[j][k],dp[j-1][k])+1
        ndp[j][b[i][j]] = 0
    dp,ndp = ndp,dp
    for j in range(w):
        ans += score(dp[j],i,j)
print(ans)
0