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

[소병희] 근손실, 비슷한 단어, 아기상어2, 트리의 부모 찾기, 회의실 배정 #27

Merged
merged 6 commits into from
Oct 23, 2022

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented Oct 22, 2022

📌 from issue #26 📌

📋문제 목록📋

근손실: ✅
비슷한 단어: ✅
아기상어2: ✅
트리의 부모 찾기: ✅
회의실 배정: ✅

📍추가로 해결한 문제📍

추천: 👍  
비추천: 👎  
문제에 대한 간단한 코멘트를 남겨주셔도 좋을 것 같아요!

📝메모

공유하고 싶은 정보, 새롭게 알게된 것, 문제를 풀면서 발생한 에로사항 등...자유롭게!



for(i in 0 until n) {
if (visited[i]) continue
if (curPerm + workouts[i] < 0) continue
Copy link
Member

Choose a reason for hiding this comment

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

독특한 방식으로 백트래킹하신 것이 기억에 남네요!

}

fun isInBound(h: Int, w: Int) : Boolean {
return r in 0 until h && c in 0 until w
Copy link
Member

Choose a reason for hiding this comment

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

Pos / isInBound를 데이터 클래스의 메서드로 만드신 점이 인상깊습니다..!!


repeat(n-1) { i ->
br.readLine().split(" ").map{ it.toInt() }.run {
edges.getOrPut(first()) { mutableListOf() }
Copy link
Member

Choose a reason for hiding this comment

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

getOrPut 좋은 것 같습니다..!!

data class Meeting(val s: Int, val e: Int)

var n = 0
val meetings = PriorityQueue(Comparator<Meeting> { a, b -> if (a.e == b.e) a.s - b.s else a.e - b.e })
Copy link
Member

Choose a reason for hiding this comment

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

우선순위 큐 자주 사용하시던데 저도 사용해봐야겠어요..!

data class Meeting(val s: Int, val e: Int)

var n = 0
val meetings = PriorityQueue(Comparator<Meeting> { a, b -> if (a.e == b.e) a.s - b.s else a.e - b.e })
Copy link
Member

Choose a reason for hiding this comment

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

PriorityQueue 써서 정렬할 수도 있군요!

n = first()
k = last()
}
workouts = br.readLine().split(" ").map { it.toInt() - k }.toIntArray()
Copy link
Member

Choose a reason for hiding this comment

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

미리 k를 뺀게 더 이해하기 좋은 것 같아요! 기본값이 변해도 상관없겠네요!


for(i in 0 until n) {
if (visited[i]) continue
if (curPerm + workouts[i] < 0) continue
Copy link
Member

Choose a reason for hiding this comment

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

계산하는 과정에서 0 미만이면 continue하는거 좋네요!


repeat(n-1) { i ->
br.readLine().split(" ").map{ it.toInt() }.run {
edges.getOrPut(first()) { mutableListOf() }
Copy link
Member

Choose a reason for hiding this comment

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

getOrPut 배우고 갑니다!


repeat(n-1) { i ->
br.readLine().split(" ").map{ it.toInt() }.run {
edges.getOrPut(first()) { mutableListOf() }
Copy link
Member

Choose a reason for hiding this comment

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

공감합니다!👍

return Pos(r + p.r, c + p.c)
}

fun isInBound(h: Int, w: Int) : Boolean {
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 d9f6710 into main Oct 23, 2022
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