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

[소병희] 연구소, 미세먼지 안녕!, 친구비, 드래곤 커브 #124

Merged
merged 5 commits into from
Mar 26, 2023

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented Mar 26, 2023

📌 from issue #120 📌

📋문제 목록📋

연구소: ✅
미세먼지 안녕!: ✅
친구비: ✅
드래곤 커브: ✅

@bngsh bngsh added the 병희 label Mar 26, 2023
@bngsh bngsh self-assigned this Mar 26, 2023
Comment on lines +40 to +44
for(i in 0 until g) {
r += dr[(d + curves[i]) % 4]
c += dc[(d + curves[i]) % 4]
isDragon[r][c] = true
}
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 +67 to +83
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)
}
Copy link
Member

Choose a reason for hiding this comment

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

아니 이걸 -1 을 곱해서 하실 생각을

Comment on lines +29 to +33
val (p1, p2) = readLine().split(" ").map { getParent(it.toInt()) }
if (p1 != p2) {
parent[p2] = p1
cost[p1] = cost[p1].coerceAtMost(cost[p2])
}
Copy link
Member

Choose a reason for hiding this comment

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

바로 Parent 를 찾고 합치는!! 👍👍👍

Comment on lines +30 to +37
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)
}
}
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 +37 to +41
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]
}
}
Copy link
Member

Choose a reason for hiding this comment

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

copy를 써서 그런가?? 시간이 훠어얼씬 적게 드시네요??

Comment on lines +62 to +72
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)
}
Copy link
Member

Choose a reason for hiding this comment

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

Int 하나로 2차원 리스트를 도는법 배워갑니다 👍

Comment on lines +34 to +36
for(i in curves.size - 1 downTo 0) {
curves.add((curves[i] + 1) % 4)
}
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 +37 to +41
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]
}
}
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 +29 to +33
val (p1, p2) = readLine().split(" ").map { getParent(it.toInt()) }
if (p1 != p2) {
parent[p2] = p1
cost[p1] = cost[p1].coerceAtMost(cost[p2])
}
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 ab226cb into main Mar 26, 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