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

[소병희] 표현 가능한 이진트리, 절댓값 힙, 치즈, 치킨 배달 #112

Merged
merged 5 commits into from
Mar 12, 2023

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented Mar 9, 2023

📌 from issue #111 📌

📋문제 목록📋

표현 가능한 이진트리: ✅
절댓값 힙: ✅
치즈: ✅
치킨 배달: ✅

@bngsh bngsh added the 병희 label Mar 9, 2023
@bngsh bngsh self-assigned this Mar 9, 2023
companion object {
fun solve(): Unit = with(BufferedReader(InputStreamReader(System.`in`))) {
val n = readLine().toInt()
val pq = PriorityQueue<Int> { a, b -> if (a + b == 0) a - b else abs(a) - abs(b) }
Copy link
Member

Choose a reason for hiding this comment

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

pq를 굉장히 아름답게 쓰시네요,, 항상 배우고 갑니당

Comment on lines +34 to +42
fun checkSubTree(s: Int, e: Int, parent: Int) : Int {
val mid = (s + e) / 2
val root = sb[mid] - '0'
if (root == 1 && parent == 0) return 0
if (s == e) return 1

if (checkSubTree(s, mid - 1, root) == 0) return 0
return checkSubTree(mid + 1, e, root)
}
Copy link
Member

Choose a reason for hiding this comment

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

재귀 장인이시군요

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 +34 to +42
fun checkSubTree(s: Int, e: Int, parent: Int) : Int {
val mid = (s + e) / 2
val root = sb[mid] - '0'
if (root == 1 && parent == 0) return 0
if (s == e) return 1

if (checkSubTree(s, mid - 1, root) == 0) return 0
return checkSubTree(mid + 1, e, root)
}
Copy link
Member

Choose a reason for hiding this comment

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

인졍..!


val houseCnt = house.size
val franchiseCnt = franchise.size
val distMap = Array(houseCnt) { h -> IntArray(franchiseCnt) { f -> house[h].calcDist(franchise[f]) } }
Copy link
Member

Choose a reason for hiding this comment

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

거리를 미리 저장하시다니!👍

val m = input()
val house = mutableListOf<Pair<Int, Int>>()
val franchise = mutableListOf<Pair<Int, Int>>()
var cityDist = Integer.MAX_VALUE
Copy link
Member

Choose a reason for hiding this comment

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

Int의 상수 대신 Interger의 상수를 사용하신 이유가 있으신가요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ㅇㅁㅇ 아뇨 자바랑 헷갈렸나봐요 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

}

fun makeM(f: Int, i: Int, chickenDist: IntArray) {
if (f == franchiseCnt && i < m) return
Copy link
Member

Choose a reason for hiding this comment

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

조건처리가 좋은 것 같습니다..!!!


for(i in numbers.indices) {
sb.clear()
sb.append(java.lang.Long.toBinaryString(numbers[i]))
Copy link
Member

Choose a reason for hiding this comment

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

Long도 toBinaryString이 있군요...

@bngsh bngsh merged commit 50c10a8 into main Mar 12, 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