AtCoder Beginner Contest 007

Submission #3732816

Source codeソースコード

row, col = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
grid = [input() for r in range(row)]
grid = [[c for c in cols] for cols in grid]
grid[sy-1][sx-1] = 0
loc = [[sy-1, sx-1]]

for tri in range(1, row*col):
    next_loc = []
    
    for y, x in loc:
        if grid[y][x+1] == '.':
            grid[y][x+1] = tri
            next_loc.append([y, x+1])
            
        if grid[y+1][x] == '.':
            grid[y+1][x] = tri
            next_loc.append([y+1, x])
            
        if grid[y][x-1] == '.':
            grid[y][x-1] = tri
            next_loc.append([y, x-1])
            
        if grid[y-1][x] == '.':
            grid[y-1][x] = tri
            next_loc.append([y-1, x])
            
    loc = next_loc
    
    if [gy-1, gx-1] in loc:
        break
        
print(tri)

Submission

Task問題 C - 幅優先探索
User nameユーザ名 Masa0u0
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 100
Source lengthソースコード長 879 Byte
File nameファイル名
Exec time実行時間 21 ms
Memory usageメモリ使用量 3188 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample01.txt,subtask0_sample02.txt,subtask0_sample03.txt
All 100 / 100 subtask0_sample01.txt,subtask0_sample02.txt,subtask0_sample03.txt,subtask1_01.txt,subtask1_02.txt,subtask1_03.txt,subtask1_04.txt,subtask1_05.txt,subtask1_06.txt,subtask1_07.txt,subtask1_08.txt,subtask1_09.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask1_20.txt,subtask1_21.txt,subtask1_22.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_sample01.txt AC 17 ms 3064 KB
subtask0_sample02.txt AC 17 ms 3064 KB
subtask0_sample03.txt AC 20 ms 3064 KB
subtask1_01.txt AC 19 ms 3064 KB
subtask1_02.txt AC 19 ms 3064 KB
subtask1_03.txt AC 18 ms 3064 KB
subtask1_04.txt AC 20 ms 3064 KB
subtask1_05.txt AC 19 ms 3064 KB
subtask1_06.txt AC 19 ms 3064 KB
subtask1_07.txt AC 21 ms 3188 KB
subtask1_08.txt AC 18 ms 3064 KB
subtask1_09.txt AC 19 ms 3064 KB
subtask1_10.txt AC 18 ms 3064 KB
subtask1_11.txt AC 20 ms 3064 KB
subtask1_12.txt AC 19 ms 3064 KB
subtask1_13.txt AC 19 ms 3064 KB
subtask1_14.txt AC 18 ms 3064 KB
subtask1_15.txt AC 19 ms 3064 KB
subtask1_16.txt AC 19 ms 3064 KB
subtask1_17.txt AC 20 ms 3064 KB
subtask1_18.txt AC 19 ms 3064 KB
subtask1_19.txt AC 19 ms 3064 KB
subtask1_20.txt AC 19 ms 3064 KB
subtask1_21.txt AC 19 ms 3064 KB
subtask1_22.txt AC 19 ms 3064 KB