-
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
[소병희] 케빈 베이컨의 6단계 법칙, 전구와 스위치, CCW, 함께 블록 쌓기 #174
Conversation
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.
고생하셨습니다!
val n = readLine().toInt() | ||
val origin = readLine().map { it == '1' } | ||
val goal = readLine().map { it == '1' } | ||
val arr = BooleanArray(n+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.
오 true/false로 연산을 하셨군요
for(k in 1..n) for(i in 1 .. n) for(j in 1 .. n) { | ||
adj[i][j] = minOf(adj[i][k] + adj[k][j], adj[i][j]) | ||
} | ||
|
||
for(i in 1 .. n) { | ||
adj[i][0] = 0 | ||
for(j in 1 .. n) adj[i][0] += adj[i][j] | ||
if (bacon > adj[i][0]) { | ||
bacon = adj[i][0] | ||
ans = i | ||
} | ||
} |
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.
헉 플로이드 워셜...
readLine().split(" ").forEach { | ||
val j = it.toInt() | ||
for(k in 0 .. h - j) { | ||
dp[i+1][k + j] = (dp[i+1][k + j] + dp[i][k]) % MOD | ||
} | ||
} |
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.
입력을 받으면서 테이블을 갱신하는 건 생각치도 못했네요..
val n = readLine().toInt() | ||
val origin = readLine().map { it == '1' } | ||
val goal = readLine().map { it == '1' } | ||
val arr = BooleanArray(n+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.
나도 하나 더 만들 걸...
arr[s+1] = arr[s+1].not() | ||
} | ||
} | ||
if (arr[n-1] != goal[n-1]) cnt1 = INF |
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.
마지막만 비교!👍👍
for(k in 1..n) for(i in 1 .. n) for(j in 1 .. n) { | ||
adj[i][j] = minOf(adj[i][k] + adj[k][j], adj[i][j]) | ||
} |
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.
오랜만에 플로이드 워셜!!
for(k in 1..n) for(i in 1 .. n) for(j in 1 .. n) { | ||
adj[i][j] = minOf(adj[i][k] + adj[k][j], adj[i][j]) | ||
} |
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.
플루이드 워셜인지 몰랐는데 이렇게도 풀 수 있군요 👍
val n = readLine().toInt() | ||
val origin = readLine().map { it == '1' } | ||
val goal = readLine().map { it == '1' } | ||
val arr = BooleanArray(n+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.
이렇게 하니까 훨 편하네요
역시 병희님 !!!
arr[s+1] = arr[s+1].not() | ||
} | ||
} | ||
if (arr[n-1] != goal[n-1]) cnt1 = INF |
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.
쩔어쩔어
val j = it.toInt() | ||
for(k in 0 .. h - j) { | ||
dp[i+1][k + j] = (dp[i+1][k + j] + dp[i][k]) % MOD | ||
} |
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 #170 📌
📋문제 목록📋