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

[소병희] - 최소 스패닝 트리, 카드 섞기, 경쟁적 전염, Coins #257

Merged
merged 1 commit into from
May 17, 2024

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented May 12, 2024

📌 from issue #256 📌

📋문제 목록📋

최소 스패닝 트리, 카드 섞기, 경쟁적 전염, Coins: ✅

@bngsh bngsh changed the title 소병희 - 최소 스패닝 트리, 카드 섞기, 경쟁적 전염, Coins [소병희] 최소 스패닝 트리, 카드 섞기, 경쟁적 전염, Coins May 12, 2024
@bngsh bngsh changed the title [소병희] 최소 스패닝 트리, 카드 섞기, 경쟁적 전염, Coins [소병희] - 최소 스패닝 트리, 카드 섞기, 경쟁적 전염, Coins May 12, 2024
val nc = c + dc[d]
if (nr !in 0 until n || nc !in 0 until n) continue
if (tube[nr][nc] in 1 until tube[r][c]) continue
if (tube[nr][nc] > 0 && time[nr][nc] <= time[r][c]) continue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

순간 헷갈렸는데 time[nr][nc]를 갱신하기 전이라 이 비교가 맞네요 허허

Comment on lines +17 to +37
while(pq.isNotEmpty()) {
val (a, b, w) = pq.poll()

var parA = a
var parB = b

while(visited[parA] != parA) {
parA = visited[parA]
}
while(visited[parB] != parB) {
parB = visited[parB]
}

if (parA == parB) continue

if (parA < parB) {
visited[parB] = parA
}
else {
visited[parA] = parB
}
Copy link
Member

Choose a reason for hiding this comment

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

반례 제공도 감사드리고 병희님 코드 참고하면서 문제도 풀었습니다!!👍

Copy link
Member

Choose a reason for hiding this comment

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

맞아유 반례 덕분에 저도 이해됐어요!!!

Comment on lines +31 to +32
if (tube[nr][nc] in 1 until tube[r][c]) continue
if (tube[nr][nc] > 0 && time[nr][nc] <= time[r][c]) continue
Copy link
Member

Choose a reason for hiding this comment

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

아 이 친구들이 번호의 우선순위와 이전 영역의 침범을 막는 코드군요!👍

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.

고생하셨습니다!!

Comment on lines +18 to +23
dp[0] = 1
for(coin in coins) {
for(price in coin .. m) {
dp[price] += dp[price - coin]
}
}
Copy link
Member

Choose a reason for hiding this comment

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

다들 1차원으로 깔끔하게 하시는군요

Comment on lines +20 to +37
var parA = a
var parB = b

while(visited[parA] != parA) {
parA = visited[parA]
}
while(visited[parB] != parB) {
parB = visited[parB]
}

if (parA == parB) continue

if (parA < parB) {
visited[parB] = parA
}
else {
visited[parA] = parB
}
Copy link
Member

Choose a reason for hiding this comment

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

오오.. 요런식으로도,,,

shuffle[i] = v.toInt()
}

for(i in 0 .. 1_000_000) {
Copy link
Member

Choose a reason for hiding this comment

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

참신했습니다. 역시 병희님

Comment on lines +34 to +35
tube[nr][nc] = tube[r][c]
time[nr][nc] = time[r][c] + 1
Copy link
Member

Choose a reason for hiding this comment

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

time을 이용해서 순서를 정하는게 좋아보였습니다!

Comment on lines +17 to +37
while(pq.isNotEmpty()) {
val (a, b, w) = pq.poll()

var parA = a
var parB = b

while(visited[parA] != parA) {
parA = visited[parA]
}
while(visited[parB] != parB) {
parB = visited[parB]
}

if (parA == parB) continue

if (parA < parB) {
visited[parB] = parA
}
else {
visited[parA] = parB
}
Copy link
Member

Choose a reason for hiding this comment

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

맞아유 반례 덕분에 저도 이해됐어요!!!

@bngsh bngsh merged commit 0e5be66 into main May 17, 2024
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.

4 participants