Submission #9476488
Source Code Expand
Copy
import mathimport sysm=10**9 + 7sys.setrecursionlimit(1000010)INF = 10 ** 2(H, W) = list(map(int,input().split()))# print(H,W)S = []N = H * Wc = [[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] = 0d[k][k] = 0for i in range(H):S.append(input())
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)
Submission Info
Submission Time | |
---|---|
Task | D - Maze Master |
User | MyOden |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1753 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 7796 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
hand_01 | TLE | 2104 ms | 5748 KB |
hand_02 | TLE | 2104 ms | 5748 KB |
hand_03 | TLE | 2104 ms | 5748 KB |
hand_04 | TLE | 2104 ms | 5748 KB |
hand_05 | TLE | 2104 ms | 5748 KB |
hand_06 | TLE | 2104 ms | 5748 KB |
hand_07 | TLE | 2104 ms | 7796 KB |
hand_08 | TLE | 2104 ms | 5748 KB |
hand_09 | TLE | 2104 ms | 3572 KB |
hand_10 | TLE | 2104 ms | 3828 KB |
sample_01 | AC | 18 ms | 3192 KB |
sample_02 | AC | 20 ms | 3192 KB |
small_01 | AC | 18 ms | 3192 KB |
small_02 | AC | 22 ms | 3192 KB |
small_03 | TLE | 2104 ms | 5620 KB |
small_04 | AC | 22 ms | 3192 KB |