-
Notifications
You must be signed in to change notification settings - Fork 0
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
[이지민] - 북쪽나라의 도로, 숫자고르기, 연구소2 #204
Conversation
def dfs(first, second, now): | ||
first.add(now) | ||
second.add(numbers[now]) | ||
if numbers[now] in first: | ||
if first == second: | ||
answer.update(first) | ||
return | ||
return | ||
return dfs(first, second, numbers[now]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set을 인자로 받아서 재귀 구조가 엄청 깔끔한 게 멋졌습니다
nx, ny = queue.popleft() | ||
|
||
for i in range(4): | ||
if 0 <= nx + dx[i] < n and 0 <= ny + dy[i] < n and visited[nx + dx[i]][ny + dy[i]] == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
조건문 하나로 다 처리하는 게 함수가 깨끗해서 좋네요
|
||
visited = [-1 for _ in range(10_001)] | ||
bfs(1) | ||
s = visited.index(max(visited)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visited 로 거리를 모으시고 계산하신 게 좋았슴다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다..!!!
a, b, c = map(int, sys.stdin.readline().split()) | ||
roads[a].append([b, c]) | ||
roads[b].append([a, c]) | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 except 도 있군요,,
dfs(set(), set(), i) | ||
|
||
print(len(answer)) | ||
for num in sorted(list(answer)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오.... 파이썬도 순수함수가 있군요??
possible.append([i, j]) | ||
|
||
|
||
for combi in combinations(possible, m): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파이썬도 뭔가 야무진 함수가 많네요
📌 from issue #201 📌
📋문제 목록📋