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

12-SeongHoonC #45

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SeongHoonC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
| 9μ°¨μ‹œ | 2024.02.21 | bfs | <a href="https://www.acmicpc.net/problem/21736"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/35 |
| 10μ°¨μ‹œ | 2024.02.23 | 그리디 | <a href="https://www.acmicpc.net/problem/1931"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/38 |
| 11μ°¨μ‹œ | 2024.02.26 | μž¬κ·€ | <a href="https://www.acmicpc.net/problem/1074"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/40 |
| 12μ°¨μ‹œ | 2024.02.29 | 뢄할정볡 | <a href="https://www.acmicpc.net/problem/2630"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/45 |
---
41 changes: 41 additions & 0 deletions SeongHoonC/뢄할정볡/blue.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import java.io.BufferedReader
import java.io.InputStreamReader

var blue = 0
var white = 0
fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val n = br.readLine().toInt()
val paper = Array(n) { Array(n) { 0 } }

for (i in 0 until n) {
val line = br.readLine().split(" ").map { it.toInt() }
for (j in 0 until n) {
paper[i][j] = line[j]
}
}

cut(0, 0, n, paper)
println(white)
println(blue)
}

private fun cut(x: Int, y: Int, n: Int, paper: Array<Array<Int>>) {
if (checkPaper(x = x, y = y, n = n, paper = paper, target = 1) { blue++ }) return
if (checkPaper(x = x, y = y, n = n, paper = paper, target = 0) { white++ }) return

val divN = n / 2
Copy link
Member

Choose a reason for hiding this comment

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

μ΄λ ‡κ²Œ n//2뢀뢄을 κ·Έλƒ₯ 보기 νŽΈν•˜κ²Œ λ§Œλ“€ 수 μžˆλ„€μš”!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

λ³€μˆ˜λ₯Ό λ”°λ‘œ μ €μž₯ν•˜μ§€ μ•Šμ•„λ„ μ»΄νŒŒμΌλŸ¬κ°€ μ΅œμ ν™”ν•΄μ„œ μ—¬λŸ¬λ²ˆ 연산이 μΌμ–΄λ‚˜μ§„ μ•Šκ² μ§€λ§Œ..개인적으둜 λ‹€λ₯Έ μ‚¬λžŒμ΄ μ΄ν•΄ν•˜κΈ° 쉽도둝 이름 μ§€μ–΄μ£ΌλŠ” νŽΈμž…λ‹ˆλ‹Ή!

cut(x, y, divN, paper)
cut(x + divN, y, divN, paper)
cut(x, y + divN, divN, paper)
cut(x + divN, y + divN, divN, paper)
}

private fun checkPaper(x: Int, y: Int, n: Int, paper: Array<Array<Int>>, target: Int, action: () -> Unit): Boolean {
val isSame = (x until x + n).all { dx -> (y until y + n).all { dy -> paper[dx][dy] == target } }
if (isSame) {
action()
return true
}
return false
}
Loading