[백준] 4963번 섬의 개수
굉장히 쉬운 문제.. 푸는데 20분도 안걸림... # 4963번 from queue import Queue import sys direction = [[-1, 0], [1, 0], [0, 1], [0, -1], [-1, -1], [1, 1], [-1, 1], [1, -1]] def bfs(x, y): que = Queue() que.put([x, y]) visited[x][y] = 1 while not que.empty(): tx, ty = que.get() for i in range(len(direction)): nx = tx + direction[i][0] ny = ty + direction[i][1] if 0
2020. 9. 14.
[백준] 7576번 토마토
몇일전에 모양만 따놨는데 안되서 고통받다가.. 어떻게 풀었는데 시간초과 떠서 고통받다가... 필요없는 프로세스 싹다 지우고 코드 간략화해서 성공... ㅠㅠ 점점 어려워진다.. 아닌가.. 아니 뭔가 알꺼같은데 어렵다.. 근데 막상 풀고 나면 쉽다.. # 7576번 from collections import deque import sys x, y = map(int, input().split()) direction = [[-1, 0], [1, 0], [0, 1], [0, -1]] mapData = [[0] * x for _ in range(y)] def bfs(tQ): counter = -1 while tQ: counter += 1 for _ in range(len(tQ)): tx, ty = tQ.poplef..
2020. 9. 14.