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

[소병희] 케빈 베이컨의 6단계 법칙, 전구와 스위치, CCW, 함께 블록 쌓기 #174

Merged
merged 6 commits into from
Sep 11, 2023

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented Sep 11, 2023

📌 from issue #170 📌

📋문제 목록📋

케빈 베이컨의 6단계 법칙: ✅
전구와 스위치: ⛔️
CCW: ⛔️
함께 블록 쌓기: ✅

@bngsh bngsh added the 병희 label Sep 11, 2023
@bngsh bngsh self-assigned this Sep 11, 2023
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.

고생하셨습니다!

val n = readLine().toInt()
val origin = readLine().map { it == '1' }
val goal = readLine().map { it == '1' }
val arr = BooleanArray(n+1)
Copy link
Member

Choose a reason for hiding this comment

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

오 true/false로 연산을 하셨군요

Comment on lines +21 to +32
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
}
}
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 16 to 21
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
}
}
Copy link
Member

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)
Copy link
Member

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
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 +21 to +23
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])
}
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 +21 to +23
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])
}
Copy link
Member

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)
Copy link
Member

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
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 17 to 20
val j = it.toInt()
for(k in 0 .. h - j) {
dp[i+1][k + j] = (dp[i+1][k + j] + dp[i][k]) % MOD
}
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 f901d51 into main Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants