Skip to content

Conversation

@MoiJiyeon
Copy link
Collaborator

스크린샷 2024-08-30 22 16 33

close #38

@MoiJiyeon MoiJiyeon self-assigned this Aug 30, 2024
Copy link
Collaborator

@timepresent95 timepresent95 left a comment

Choose a reason for hiding this comment

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

전형적인 문제들이 많아서 풀이가 다 비슷하긴하지만
그 안에서 사용하는 문법들은 여전히 달라서 보는 즐거움이 있네요 ㅎㅎ
이번 주차도 고생 많으셨습니다!

Comment on lines +3 to +8
N, *edges = map(int, open(0).read().split()) # edges = [1, 6, 6, 3, ...]
tree = [[] for _ in range(N + 1)]

for a, b in zip(edges[::2], edges[1::2]): # 2씩 건너뛰며 zip [1, 6], [6, 3], ...
tree[a] += [b] # 연결된 노드 리스트 저장
tree[b] += [a]
Copy link
Collaborator

Choose a reason for hiding this comment

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

zip을 활용하는 방법이 정말 파이썬 스럽고 좋네요 ㅎㅎ

from itertools import permutations, starmap

# open(0) : 표준 입력 받아오기
NM, nums = [*open(0)] # NM = "3 1\n", nums = "4 4 2\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

한줄씩 값을 받아올때 정말 편하겠네요
좋은거 하나 알아갑니다!

Copy link
Collaborator

@HanMulBit HanMulBit left a comment

Choose a reason for hiding this comment

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

평소에 *을 잘 안쓰게 되었었는데 쓰는 방법 많이 배운 것 같아요
이번 주차도 고생많으셨어요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[luna] - class4-1

4 participants