-
Notifications
You must be signed in to change notification settings - Fork 830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
경쟁적 전염 질문 #192
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from collections import deque
n, k = map(int, input().split())
graph = [] # 전체 맵 리스트
data = [] # 바이러스 정보
for i in range(n):
graph.append(list(map(int, input().split())))
for j in range(n):
# 해당 위치에 바이러스가 존재하는 경우
if graph[i][j] != 0:
# (바이러스 종류, 시간, X좌표, Y좌표) 삽입
data.append((graph[i][j], 0, i, j))
data.sort()
q = deque(data)
target_s, target_x, target_y = map(int, input().split())
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
while q:
virus, s, x, y = q.popleft()
# s초가 지나거나, 큐가 빌때 까지 반복
if s == target_s:
break
print(graph[target_x - 1][target_y - 1])
위 코드에서 q에서 data를 삽입 할때
q = deque(data) 말고
q = deque()
q.append(data)
이런식으로 하면 백준에서 런타임 에러(ValueError)라고 뜨던데 그 이유를 모르겠습니다.
The text was updated successfully, but these errors were encountered: