-
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
[소병희] 근손실, 비슷한 단어, 아기상어2, 트리의 부모 찾기, 회의실 배정 #27
Conversation
|
||
for(i in 0 until n) { | ||
if (visited[i]) continue | ||
if (curPerm + workouts[i] < 0) 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.
독특한 방식으로 백트래킹하신 것이 기억에 남네요!
} | ||
|
||
fun isInBound(h: Int, w: Int) : Boolean { | ||
return r in 0 until h && c in 0 until w |
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.
Pos / isInBound를 데이터 클래스의 메서드로 만드신 점이 인상깊습니다..!!
|
||
repeat(n-1) { i -> | ||
br.readLine().split(" ").map{ it.toInt() }.run { | ||
edges.getOrPut(first()) { mutableListOf() } |
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.
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 }) |
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.
우선순위 큐 자주 사용하시던데 저도 사용해봐야겠어요..!
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 }) |
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.
PriorityQueue 써서 정렬할 수도 있군요!
n = first() | ||
k = last() | ||
} | ||
workouts = br.readLine().split(" ").map { it.toInt() - k }.toIntArray() |
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.
미리 k를 뺀게 더 이해하기 좋은 것 같아요! 기본값이 변해도 상관없겠네요!
|
||
for(i in 0 until n) { | ||
if (visited[i]) continue | ||
if (curPerm + workouts[i] < 0) 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.
계산하는 과정에서 0 미만이면 continue하는거 좋네요!
|
||
repeat(n-1) { i -> | ||
br.readLine().split(" ").map{ it.toInt() }.run { | ||
edges.getOrPut(first()) { mutableListOf() } |
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.
getOrPut 배우고 갑니다!
|
||
repeat(n-1) { i -> | ||
br.readLine().split(" ").map{ it.toInt() }.run { | ||
edges.getOrPut(first()) { mutableListOf() } |
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.
공감합니다!👍
return Pos(r + p.r, c + p.c) | ||
} | ||
|
||
fun isInBound(h: Int, w: Int) : Boolean { |
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 #26 📌
📋문제 목록📋
📍추가로 해결한 문제📍
📝메모
공유하고 싶은 정보, 새롭게 알게된 것, 문제를 풀면서 발생한 에로사항 등...자유롭게!