-
Notifications
You must be signed in to change notification settings - Fork 0
[luna] - class4-1 #42
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
base: main
Are you sure you want to change the base?
Conversation
timepresent95
left a comment
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.
전형적인 문제들이 많아서 풀이가 다 비슷하긴하지만
그 안에서 사용하는 문법들은 여전히 달라서 보는 즐거움이 있네요 ㅎㅎ
이번 주차도 고생 많으셨습니다!
| 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] |
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.
zip을 활용하는 방법이 정말 파이썬 스럽고 좋네요 ㅎㅎ
| from itertools import permutations, starmap | ||
|
|
||
| # open(0) : 표준 입력 받아오기 | ||
| NM, nums = [*open(0)] # NM = "3 1\n", nums = "4 4 2\n" |
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.
한줄씩 값을 받아올때 정말 편하겠네요
좋은거 하나 알아갑니다!
HanMulBit
left a comment
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.
평소에 *을 잘 안쓰게 되었었는데 쓰는 방법 많이 배운 것 같아요
이번 주차도 고생많으셨어요!
close #38