-
[백준 문제풀이] 얼렁뚱땅 9205 맥주 마시면서 걸어가기 풀이얼렁뚱땅 백준 문제풀이 2022. 9. 9. 16:24
https://www.acmicpc.net/problem/9205
9205번: 맥주 마시면서 걸어가기
송도에 사는 상근이와 친구들은 송도에서 열리는 펜타포트 락 페스티벌에 가려고 한다. 올해는 맥주를 마시면서 걸어가기로 했다. 출발은 상근이네 집에서 하고, 맥주 한 박스를 들고 출발한다.
www.acmicpc.net
from collections import deque def dfs(visited,x,y) : global where, rock_x, rock_y, market, sign if abs(rock_x - x) + abs(rock_y - y) <= 1000 : sign = 1 for k in range(market) : if (visited[k]==1): continue if abs(where[k][0]-x) + abs(where[k][1]-y) <= 1000 : visited[k]=1 dfs(visited, where[k][0], where[k][1]) t = int(input()) for _ in range(t) : market = int(input()) house_x, house_y = map(int,input().split()) where = [] visited = [0] * market for j in range(market) : temp = list(map(int,input().split())) where.append(temp) rock_x, rock_y = map(int,input().split()) sign = 0 dfs(visited,house_x,house_y) if sign==1 : print('happy') else : print('sad')
'얼렁뚱땅 백준 문제풀이' 카테고리의 다른 글
[백준 문제풀이] 얼렁뚱땅 9935 문자열폭발 풀이 (0) 2022.09.16 [백준 문제풀이] 얼렁뚱땅 11060 점프점프 풀이 (0) 2022.09.09 [백준 문제풀이] 얼렁뚱당 15686 치킨배달 풀이 (0) 2022.09.07 [백준 문제풀이] 얼렁뚱땅 14891 톱니바퀴 풀이 (0) 2022.09.07 [백준 문제풀이] 얼렁뚱땅 15685 드래곤 커브 (0) 2022.09.07