๋ฌธ์ ํ์ด ์ธ์ด Kotiln ์ฝ๋ import java.lang.Integer.max import java.util.* var n = 0 var m = 0 var max_value = 0 val dx = listOf(-1, 1, 0, 0) val dy = listOf(0, 0, -1, 1) lateinit var board: Array lateinit var check: Array fun main() = with(Scanner(System.`in`)) { n = nextInt() m = nextInt() board = Array(n) { Array(m) { "" } } check = Array(26) { 0 } for (i in 0 until n) { val s = next().chunked(1) for..
๋ฌธ์ ํ์ด ์ธ์ด Kotlin ์ฝ๋ import java.util.* import kotlin.math.abs lateinit var array: Array var n = 0 var cnt = 0 fun main() = with(Scanner(System.`in`)) { n = nextInt() array = Array(n) { 0 } nQueen(0) println(cnt) } fun nQueen(depth: Int) { // depth๋ row if (depth == n) { println(depth) cnt++ return } for (i in 0 until n) { // i๋ col array[depth] = i if (check(depth)) { nQueen(depth + 1) } } } fun ..
N๊ณผ M (1) ๋ฌธ์ ํ์ด ์ธ์ด Kotlin ์ฝ๋ import java.util.* lateinit var visit: Array lateinit var input: Array var n: Int = 0 var m: Int = 0 fun main() = with(Scanner(System.`in`)) { n = nextInt() m = nextInt() visit = Array(n + 1) { 0 } input = Array(n + 1) { 0 } dfs(0) } fun dfs(depth: Int) { if (depth == m) { for (i in 0 until m) { print("${input[i]} ") } println() return } for (i in 0 until n) { if (vis..