結果

問題 No.323 yuki国
ユーザー roarisroaris
提出日時 2019-12-08 20:11:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 859 bytes
コンパイル時間 1,617 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 253,332 KB
最終ジャッジ日時 2023-08-30 04:02:06
合計ジャッジ時間 10,885 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,732 KB
testcase_01 AC 123 ms
77,476 KB
testcase_02 AC 93 ms
71,616 KB
testcase_03 AC 162 ms
81,816 KB
testcase_04 AC 111 ms
77,712 KB
testcase_05 AC 126 ms
78,332 KB
testcase_06 AC 110 ms
77,736 KB
testcase_07 AC 93 ms
71,560 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 92 ms
71,600 KB
testcase_11 AC 101 ms
77,568 KB
testcase_12 AC 104 ms
77,520 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,390 ms
189,440 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 938 ms
125,540 KB
testcase_19 AC 2,632 ms
178,692 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def bfs():
    q = deque([(Si, Sj, A)])
    visited = [[[False]*(5000) for _ in range(W)] for _ in range(H)]
    visited[Si][Sj][A] = True
    
    while q:
        cx, cy, s = q.popleft()
        
        for nx, ny in [(cx-1, cy), (cx+1, cy), (cx, cy-1), (cx, cy+1)]:
            if not (0<=nx<H and 0<=ny<W):
                continue
            
            ns = s+(1 if M[nx][ny]=='*' else -1)
            
            if ns==0 or ns>=5000:
                continue
            
            if not visited[nx][ny][ns]:
                visited[nx][ny][ns] = True
                q.append((nx, ny, ns))

    return visited[Gi][Gj][B]

H, W = map(int, input().split())
A, Si, Sj = map(int, input().split())
B, Gi, Gj = map(int, input().split())
M = [input() for _ in range(H)]

if bfs():
    print('Yes')
else:
    print('No')
0