-
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, 함께 블록 쌓기 #172
Conversation
val vectorP1P2 = Vector(p2X - p1X, p2Y - p1Y) | ||
val vectorP1P3 = Vector(p3X - p1X, p3Y - p1Y) |
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 queue = ArrayDeque<Pair<Int, Int>>() | ||
queue.add(Pair(standard, 0)) | ||
|
||
while (queue.isNotEmpty()) { | ||
val (man, count) = queue.removeFirst() | ||
if (findRelations.add(man)) { | ||
totalCount += count | ||
relations[man].forEach { | ||
if (it !in findRelations) queue.add(Pair(it, count + 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.
아 저처럼 초기 친구들 안 구하고 이렇게 해도 되겠군요...ㅋㅋㅋㅋㅋㅋㅋㅋ
val dp = MutableList(size = h + 1) { 0 } | ||
val tmpStored = MutableList(size = h + 1) { 0 } |
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.
1차원 dp 테이블 + 중복을 방지하기 위한 tmp저장소까지.. 다음에 비슷한 방식으로 시도해보겠습니다!
(vectorP1P2.x * vectorP1P3.y - vectorP1P3.x * vectorP1P2.y).run { | ||
if (this < 0) print(-1) | ||
if (this == 0) print(0) | ||
if (this > 0) print(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.
이거 아주 좋다고 생각했슴당
answers[man] = bfs(man) | ||
} | ||
val minCount = answers.min() | ||
println(answers) |
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.
ㅇ ㅔ ? 디버깅용이었나유?
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 minCount = answers.min() | ||
println(answers) | ||
println(answers.indexOfFirst { it == minCount }) |
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.
오 indexOfFirst 좋네요
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.
요거 참 좋네요
dp[index] += i | ||
dp[index] %= 10007 | ||
} | ||
tmpStored.fill(0) |
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.
헉...fill을 완전 잊고 있었네요 담엔 배열 초기화에 참고하겠습니다!
} | ||
val minCount = answers.min() | ||
println(answers) | ||
println(answers.indexOfFirst { it == minCount }) |
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.
요거 참 좋네요
state[0] = (state[0] + 1) % 2 | ||
state[1] = (state[1] + 1) % 2 |
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.
요 칭구도 좋네요!
dp[0] = 1 | ||
|
||
repeat(n) { | ||
val heights = readln().split(' ').map { it.toInt() } |
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 📌
📋문제 목록📋
📝메모
CCW?