-
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
[소병희] 연구소, 미세먼지 안녕!, 친구비, 드래곤 커브 #124
Conversation
for(i in 0 until g) { | ||
r += dr[(d + curves[i]) % 4] | ||
c += dc[(d + curves[i]) % 4] | ||
isDragon[r][c] = true | ||
} |
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.
경악을 금치 못합니다...
for(p in 0 .. 1) { | ||
ni = purifier + p | ||
nj = 0 | ||
for(d in 0 until 4) { | ||
while(ni + dr[d] * flip in rRange[p] && nj + dc[d] in 0 until c) { | ||
nroom[ni][nj] = nroom[ni + dr[d] * flip][nj + dc[d]] | ||
ni += dr[d] * flip | ||
nj += dc[d] | ||
} | ||
} | ||
nroom[purifier + p][1] = 0 | ||
nroom[purifier + p][0] = 0 | ||
flip *= -1 | ||
} | ||
|
||
copy(room, nroom) | ||
} |
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 을 곱해서 하실 생각을
val (p1, p2) = readLine().split(" ").map { getParent(it.toInt()) } | ||
if (p1 != p2) { | ||
parent[p2] = p1 | ||
cost[p1] = cost[p1].coerceAtMost(cost[p2]) | ||
} |
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.
바로 Parent 를 찾고 합치는!! 👍👍👍
g = 2.0.pow(it[3].toInt()).toInt() | ||
} | ||
|
||
while(curves.size < g) { | ||
for(i in curves.size - 1 downTo 0) { | ||
curves.add((curves[i] + 1) % 4) | ||
} | ||
} |
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 copy(a: Array<IntArray>, b: Array<IntArray>) { | ||
for(i in 0 until r) for(j in 0 until c) { | ||
a[i][j] = b[i][j] | ||
} | ||
} |
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.
copy를 써서 그런가?? 시간이 훠어얼씬 적게 드시네요??
fun putUpWall(i: Int, rest: Int) { | ||
if (rest == 0) return spreadVirus() | ||
|
||
if (lab[i / m][i % m] == BLANK) { | ||
lab[i / m][i % m] = WALL | ||
putUpWall(i + 1, rest - 1) | ||
lab[i / m][i % m] = BLANK | ||
} | ||
|
||
if (i + rest < n * m) putUpWall(i + 1, rest) | ||
} |
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.
Int 하나로 2차원 리스트를 도는법 배워갑니다 👍
for(i in curves.size - 1 downTo 0) { | ||
curves.add((curves[i] + 1) % 4) | ||
} |
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 copy(a: Array<IntArray>, b: Array<IntArray>) { | ||
for(i in 0 until r) for(j in 0 until c) { | ||
a[i][j] = b[i][j] | ||
} | ||
} |
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 (p1, p2) = readLine().split(" ").map { getParent(it.toInt()) } | ||
if (p1 != p2) { | ||
parent[p2] = p1 | ||
cost[p1] = cost[p1].coerceAtMost(cost[p2]) | ||
} |
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 #120 📌
📋문제 목록📋