๐Ÿ—๏ธ Algorithm/โน๏ธ SW Expert Academy [SWEA]

โน๏ธ[SW Expert Academy] [Python] [D4] [1210] Ladder1

Dbswnstjd 2024. 3. 15. 01:04

๋ฌธ์ œ

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14ABYKADACFAYh

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

ํ’€์ด

# 1210. [S/W ๋ฌธ์ œํ•ด๊ฒฐ ๊ธฐ๋ณธ] 2์ผ์ฐจ - Ladder1 [D4]
for _ in range(1, 11):
    tc = int(input())
    graph = [list(map(int, input().split())) for _ in range(100)]
    visited = [[0]*100 for _ in range(100)]

    start = graph[99].index(2)
    x, y = 99, start

    while x != 0:
        visited[x][y] = 1
        if y - 1 >= 0 and graph[x][y-1] and visited[x][y-1] == 0:
            y -= 1
            continue
        elif y + 1 < 100 and graph[x][y+1] and visited[x][y+1] == 0:
            y += 1
            continue
        else:
            x -= 1
    
    answer = y
    print("#{} {}".format(tc, answer))