-
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
[소병희] - 최소 스패닝 트리, 카드 섞기, 경쟁적 전염, Coins #257
Conversation
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 |
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.
순간 헷갈렸는데 time[nr][nc]를 갱신하기 전이라 이 비교가 맞네요 허허
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 | ||
} |
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.
반례 제공도 감사드리고 병희님 코드 참고하면서 문제도 풀었습니다!!👍
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.
맞아유 반례 덕분에 저도 이해됐어요!!!
if (tube[nr][nc] in 1 until tube[r][c]) continue | ||
if (tube[nr][nc] > 0 && time[nr][nc] <= time[r][c]) continue |
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.
아 이 친구들이 번호의 우선순위와 이전 영역의 침범을 막는 코드군요!👍
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.
고생하셨습니다!!
dp[0] = 1 | ||
for(coin in coins) { | ||
for(price in coin .. m) { | ||
dp[price] += dp[price - coin] | ||
} | ||
} |
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.
다들 1차원으로 깔끔하게 하시는군요
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 | ||
} |
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.
오오.. 요런식으로도,,,
shuffle[i] = v.toInt() | ||
} | ||
|
||
for(i in 0 .. 1_000_000) { |
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.
참신했습니다. 역시 병희님
tube[nr][nc] = tube[r][c] | ||
time[nr][nc] = time[r][c] + 1 |
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.
time을 이용해서 순서를 정하는게 좋아보였습니다!
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 | ||
} |
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 #256 📌
📋문제 목록📋