Skip to content
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

Merged
merged 7 commits into from
Nov 20, 2023

Conversation

jeeminimini
Copy link
Member

@jeeminimini jeeminimini commented Nov 20, 2023

📌 from issue #201 📌

📋문제 목록📋

북쪽나라의 도로: ⛔️
숫자고르기: ⛔️
연구소2: ✅

Comment on lines +18 to +26
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])
Copy link
Contributor

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:
Copy link
Contributor

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visited 로 거리를 모으시고 계산하신 게 좋았슴다!

Copy link
Member

@soopeach soopeach left a 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:
Copy link
Member

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)):
Copy link
Member

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파이썬도 뭔가 야무진 함수가 많네요

@jeeminimini jeeminimini merged commit 62ebab6 into main Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants