結果

問題 No.323 yuki国
ユーザー roarisroaris
提出日時 2019-12-08 20:14:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 4,698 ms / 5,000 ms
コード長 857 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 219,424 KB
最終ジャッジ日時 2023-08-30 04:06:50
合計ジャッジ時間 72,532 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
71,368 KB
testcase_01 AC 109 ms
77,452 KB
testcase_02 AC 96 ms
71,736 KB
testcase_03 AC 159 ms
80,988 KB
testcase_04 AC 118 ms
77,572 KB
testcase_05 AC 138 ms
78,240 KB
testcase_06 AC 121 ms
77,544 KB
testcase_07 AC 97 ms
71,624 KB
testcase_08 AC 4,229 ms
211,784 KB
testcase_09 AC 4,114 ms
211,988 KB
testcase_10 AC 98 ms
71,600 KB
testcase_11 AC 112 ms
77,076 KB
testcase_12 AC 104 ms
77,248 KB
testcase_13 AC 4,136 ms
213,108 KB
testcase_14 AC 4,271 ms
212,976 KB
testcase_15 AC 1,249 ms
169,684 KB
testcase_16 AC 4,169 ms
218,712 KB
testcase_17 AC 4,387 ms
213,324 KB
testcase_18 AC 768 ms
115,244 KB
testcase_19 AC 2,059 ms
158,956 KB
testcase_20 AC 4,519 ms
214,520 KB
testcase_21 AC 4,690 ms
219,424 KB
testcase_22 AC 4,698 ms
217,624 KB
testcase_23 AC 4,606 ms
214,556 KB
testcase_24 AC 1,256 ms
169,592 KB
testcase_25 AC 1,262 ms
169,624 KB
testcase_26 AC 4,328 ms
212,960 KB
testcase_27 AC 4,231 ms
213,172 KB
testcase_28 AC 4,606 ms
212,636 KB
testcase_29 AC 4,315 ms
213,012 KB
testcase_30 AC 97 ms
71,520 KB
testcase_31 AC 114 ms
77,496 KB
testcase_32 AC 121 ms
77,268 KB
testcase_33 AC 111 ms
77,308 KB
testcase_34 AC 120 ms
77,540 KB
testcase_35 AC 95 ms
71,524 KB
testcase_36 AC 118 ms
77,600 KB
testcase_37 AC 115 ms
77,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def bfs():
    q = deque([(Si, Sj, A)])
    visited = [[[False]*4000 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>=4000:
                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