結果

問題 No.971 いたずらっ子
ユーザー vwxyzvwxyz
提出日時 2024-05-03 06:45:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 109,824 KB
最終ジャッジ日時 2024-05-03 06:45:22
合計ジャッジ時間 3,825 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 247 ms
109,824 KB
testcase_01 AC 247 ms
109,812 KB
testcase_02 AC 201 ms
92,720 KB
testcase_03 AC 189 ms
109,824 KB
testcase_04 AC 183 ms
109,732 KB
testcase_05 AC 188 ms
109,696 KB
testcase_06 AC 152 ms
92,544 KB
testcase_07 AC 51 ms
62,976 KB
testcase_08 AC 93 ms
83,328 KB
testcase_09 AC 93 ms
83,768 KB
testcase_10 AC 45 ms
60,672 KB
testcase_11 AC 34 ms
52,224 KB
testcase_12 AC 36 ms
52,488 KB
testcase_13 AC 39 ms
59,136 KB
testcase_14 AC 65 ms
70,016 KB
testcase_15 AC 41 ms
58,752 KB
testcase_16 AC 40 ms
53,120 KB
testcase_17 AC 35 ms
52,096 KB
testcase_18 AC 33 ms
52,344 KB
testcase_19 AC 34 ms
52,480 KB
testcase_20 AC 35 ms
51,968 KB
testcase_21 AC 37 ms
52,224 KB
testcase_22 AC 37 ms
52,608 KB
testcase_23 AC 36 ms
52,480 KB
testcase_24 AC 37 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
A=[input() for h in range(H)]
inf=1<<30
dp=[[inf]*W for h in range(H)]
dp[0][0]=0
for h in range(H):
    for w in range(W):
        if h:
            dp[h][w]=min(dp[h][w],dp[h-1][w]+1)
        if w:
            dp[h][w]=min(dp[h][w],dp[h][w-1]+1)
        if A[h][w]=="k":
            dp[h][w]+=h+w
ans=dp[H-1][W-1]
print(ans)
0