結果

問題 No.971 いたずらっ子
ユーザー titiatitia
提出日時 2020-01-17 21:37:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 731 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 266,496 KB
最終ジャッジ日時 2024-04-25 01:57:06
合計ジャッジ時間 7,376 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 719 ms
265,856 KB
testcase_01 AC 731 ms
265,984 KB
testcase_02 AC 513 ms
218,624 KB
testcase_03 AC 666 ms
266,112 KB
testcase_04 AC 582 ms
255,104 KB
testcase_05 AC 649 ms
266,496 KB
testcase_06 AC 489 ms
223,360 KB
testcase_07 AC 62 ms
72,832 KB
testcase_08 AC 210 ms
125,824 KB
testcase_09 AC 201 ms
123,392 KB
testcase_10 AC 63 ms
73,856 KB
testcase_11 AC 35 ms
51,840 KB
testcase_12 AC 35 ms
51,840 KB
testcase_13 AC 43 ms
60,032 KB
testcase_14 AC 77 ms
73,984 KB
testcase_15 AC 44 ms
59,520 KB
testcase_16 AC 39 ms
53,760 KB
testcase_17 AC 36 ms
51,968 KB
testcase_18 AC 36 ms
51,968 KB
testcase_19 AC 35 ms
51,968 KB
testcase_20 AC 35 ms
52,096 KB
testcase_21 AC 35 ms
52,352 KB
testcase_22 AC 37 ms
52,608 KB
testcase_23 AC 36 ms
51,840 KB
testcase_24 AC 37 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
MAP=[list(input()) for i in range(H)]


R=[[1<<30]*W for i in range(H)]
R[0][0]=0

for x in range(H):
    for y in range(W):
        
        for z,w in [[x+1,y],[x,y+1]]:
            if 0<=z<H and 0<=w<W:
                if MAP[z][w]==".":
                    R[z][w]=min(R[z][w],R[x][y])

                else:
                    R[z][w]=min(R[z][w],R[x][y]+z+w)

print(H+W-2+R[-1][-1])         
    
0