結果

問題 No.8063 幅優先探索
ユーザー Kodai
提出日時 2020-04-01 22:36:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-06-27 11:50:59
合計ジャッジ時間 1,382 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 3 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

R, C = list(map(int, input().split(" ")))
sy, sx = list(map(int, input().split(" ")))
gy, gx = list(map(int, input().split(" ")))
field_list = []
position_list = []
for i in range(R):
    temp = input()
    temp_list = []
    for j in temp:
        temp_list.append(j)
    field_list.append(temp_list)
# print(field_list)


def BFF(x, y, count):
    if x == gx-1 and y == gy-1:
        print(count)
        exit()
    for mx, my in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        if 0 <= x+mx < C and 0 <= y+my < R:
            if (x+mx, y+my) not in position_list:
                if field_list[y+my][x+mx] == ".":
                    position_list.append((x+mx, y+my))
                    BFF(x+mx, y+my, count+1)


position_list.append((sx-1, sy-1))
BFF(sx-1, sy-1, 0)
0