ログインしてください。
提出 #9476488
ソースコード 拡げる
import math
import sys
m=10**9 + 7
sys.setrecursionlimit(1000010)
INF = 10 ** 2
(H, W) = list(map(int,input().split()))
# print(H,W)
S = []
N = H * W
c = [[INF for j in range(N)] for u in range(N)]
d = [[INF for j in range(H*W)] for u in range(H*W)]
for k in range(N):
c[k][k] = 0
d[k][k] = 0
for i in range(H):
S.append(input())
#print(S)
def vindex(i,j):
global W
return W * (i-1) + j -1
# print(vindex(H,W))
for i in range(1,H+1):
for j in range(1,W+1):
index = vindex(i,j)
s = S[i-1][j-1]
# print(index,s)
if i != 1:
index_t = vindex(i-1,j)
sup = S[i-2][j-1]
if ( s == "." and sup == "."):
d[index][index_t]=1
d[index_t][index]=1
if i != H:
index_t = vindex(i+1,j)
sup = S[i][j-1]
if ( s == "." and sup == "."):
d[index][index_t]=1
d[index_t][index]=1
if j != 1:
index_t = vindex(i,j-1)
sup = S[i-1][j-2]
if ( s == "." and sup == "."):
d[index][index_t]=1
d[index_t][index]=1
if j != W:
index_t = vindex(i,j+1)
sup = S[i-1][j]
if ( s == "." and sup == "."):
d[index][index_t]=1
d[index_t][index]=1
#print("D",d)
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j] , d[i][k]+d[k][j])
#print(k,d)
ans = 0
for i in range(N):
for j in range(N):
if (d[i][j] != INF and d[i][j] > ans):
ans = d[i][j]
print(ans)
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Maze Master |
| ユーザ | MyOden |
| 言語 | Python (3.4.3) |
| 得点 | 0 |
| コード長 | 1753 Byte |
| 結果 | TLE |
| 実行時間 | 2104 ms |
| メモリ | 7796 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 400 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_01, sample_02 |
| All | hand_01, hand_02, hand_03, hand_04, hand_05, hand_06, hand_07, hand_08, hand_09, hand_10, sample_01, sample_02, small_01, small_02, small_03, small_04 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| hand_01 | TLE | 2104 ms | 5748 KiB |
| hand_02 | TLE | 2104 ms | 5748 KiB |
| hand_03 | TLE | 2104 ms | 5748 KiB |
| hand_04 | TLE | 2104 ms | 5748 KiB |
| hand_05 | TLE | 2104 ms | 5748 KiB |
| hand_06 | TLE | 2104 ms | 5748 KiB |
| hand_07 | TLE | 2104 ms | 7796 KiB |
| hand_08 | TLE | 2104 ms | 5748 KiB |
| hand_09 | TLE | 2104 ms | 3572 KiB |
| hand_10 | TLE | 2104 ms | 3828 KiB |
| sample_01 | AC | 18 ms | 3192 KiB |
| sample_02 | AC | 20 ms | 3192 KiB |
| small_01 | AC | 18 ms | 3192 KiB |
| small_02 | AC | 22 ms | 3192 KiB |
| small_03 | TLE | 2104 ms | 5620 KiB |
| small_04 | AC | 22 ms | 3192 KiB |