[BOJ 실버1] 점프왕 쩰리 (Large)

JIHOON·2022년 5월 27일
0

문제

코드

  • 단순해서 설명할게 없네요.. DP풀듯이 경우의 수 저장하는 것 처럼 방문 가능한지만 체크하면 됩니다

fun main()  = with(System.`in`.bufferedReader()) {
    val n = readLine().toInt()
    val board=  Array(n){
        List(n){0}
    }
    repeat(n){
        board[it] = readLine().split(" ").map{it.toInt()}
    }
    val dest = Array(n){
        BooleanArray(n){false}
    }
    dest[0][0] = true
    for(i in 0 until n){
        if(dest[0][i]&&i+board[0][i]<n){
            dest[0][i+board[0][i]] = true
        }
        if(dest[i][0]&&i+board[i][0]<n) {
            dest[i + board[i][0]][0] = true
        }
    }

    for(i in 0 until n){
        for(j in 0 until n){
            if(dest[i][j]&&i+board[i][j]<n){
                dest[i+board[i][j]][j] = true
            }
            if(dest[i][j]&&j+board[i][j]<n) {
                dest[i][j+board[i][j]] = true
            }
        }
    }
    if(dest[n-1][n-1]){
        println("HaruHaru")
    }
    else{
        println("Hing")
    }
}
profile
https://github.com/Userz1-redd

0개의 댓글