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

[소병희] - 내리막 길, 치즈, 가장 긴 증가하는 부분 수열 4, 삼각 달팽이 #270

Merged
merged 1 commit into from
May 28, 2024

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented May 26, 2024

📌 from issue #266 📌

📋문제 목록📋

치즈, 가장 긴 증가하는 부분 수열 4, 삼각 달팽이: ✅
내리막 길: ⛔️

@bngsh bngsh added the 병희 label May 26, 2024
@bngsh bngsh self-assigned this May 26, 2024
idx = j
}
}
if (idx != i) dp[i].addAll(dp[idx])
Copy link
Member

Choose a reason for hiding this comment

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

오 addAll 좋아요

var airContact = Array(n) { IntArray(m) }
val q = ArrayDeque<IntArray>()
var time = 0
var cheese = 0
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

@soopeach soopeach left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Comment on lines +21 to +22
if (idx != i) dp[i].addAll(dp[idx])
dp[i].add(arr[i])
Copy link
Member

Choose a reason for hiding this comment

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

오.. 요런식으로 하면 초기화 처리를 앞에 안해줘도 되는군요!

return visited[r][c]
}

println(dfs(0, 0))
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 +13 to +29
while(side > 0) {
for(i in sl until sl + side) {
triangle[i].add(round, count++)
}

repeat(side - 1) { i ->
triangle[sl + side - 1].add(round + i + 1, count++)
}

for(i in sl + side-2 downTo sl + 1) {
triangle[i].add(triangle[i].size - round, count++)
}

round++
side -= 3
sl += 2
}
Copy link
Member

Choose a reason for hiding this comment

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

이거를 직접 구현하시다니...

sl += 2
}

return triangle.flatMap { it.toList() }.toIntArray()
Copy link
Member

Choose a reason for hiding this comment

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

flatMap 배워갑니다!

Comment on lines +14 to +20
for(i in 1 until n) {
var idx = i
for(j in i - 1 downTo 0) {
if (dp[j].last() < arr[i] && dp[j].size > dp[idx].size) {
idx = 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 +13 to +29
while(side > 0) {
for(i in sl until sl + side) {
triangle[i].add(round, count++)
}

repeat(side - 1) { i ->
triangle[sl + side - 1].add(round + i + 1, count++)
}

for(i in sl + side-2 downTo sl + 1) {
triangle[i].add(triangle[i].size - round, count++)
}

round++
side -= 3
sl += 2
}
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 +22 to +40
fun checkAir() {
airContact = Array(n) { IntArray(m) }
airContact[0][0]++
q.add(intArrayOf(0, 0))

while(q.isNotEmpty()) {
val (r, c) = q.removeFirst()
for(d in 0 until 4) {
val nr = r + dr[d]
val nc = c + dc[d]
if (nr !in 0 until n || nc !in 0 until m) continue
if (paper[nr][nc] == 0 && airContact[nr][nc] > 0) continue

airContact[nr][nc]++
if (paper[nr][nc] == 1) continue
q.add(intArrayOf(nr, nc))
}
}
}
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 dc542e5 into main May 28, 2024
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