본문 바로가기

분류 전체보기

[백준] 적록 색약 queue에 넣으면서 4개의 경로방향으로 전부 탐색,전체 경로를 훑으면서 안간곳을 탐색하며 전체 갯수를 구하는데, 모든 반례를 질문게시판에 찾으면서 테스트해도 실패..    fun main() = with(Scanner(System.`in`)) { val size = nextInt() val letterArray = Array(size) { CharArray(size) } for (i in 0 until size) { letterArray[i] = readln().toCharArray() } fun bfs(hasRGB: Boolean): Int { val queue = LinkedList() val isVisited = Array>(size..
[백준] 소수 경로 https://www.acmicpc.net/problem/1963 fun main() = with(Scanner(System.`in`)) { val size = nextInt() val sosu = searchSosu() fun bfs(current : Int , end : Int) : Int { val queue = LinkedList() queue.add(MyNumber(end = end, count = 0, current = current)) val isVisited = Array(10001) { false } isVisited[current] = true while (queue.isNotEmpty()) { ..
[백준] RGB 거리 https://www.acmicpc.net/problem/1149 fun main() = with(Scanner(System.`in`)) { val size = nextInt() val count = Array(size * 3) { 0 } for (i in count.indices) { count[i] = nextInt() } val dp = Array(count.size) { Int.MAX_VALUE } for (i in 0..2) { dp[i] = count[i] } for (i in 0 until size - 1) { for (j in 0..2) { if (j == 0) { ..
[백준] 카드구매하기 https://www.acmicpc.net/problem/11052 fun main() = with(Scanner(System.`in`)) { val count = nextInt() val array: Array = Array(count) { 0 } for (i in 0 until count) { array[i] = nextInt() } val dp = Array(array.size + 1) { 0 } for (i in array.indices) { dp[i + 1] = array[i] } for (i in 1 .. count) { for (j in 1 .. i) { dp[i] = max(dp[i], dp..
[백준] 1,2,3 더하기 https://www.acmicpc.net/problem/9095fun main() = with(Scanner(System.`in`)) { val number = nextInt() val array = Array(number) { 0 } for (i in array.indices) { array[i] = nextInt() } for (i in array) { var count = 0; fun dfs(total: Int) { if (total >= i) { if (total == i) { count++ } re..
[백준] 1로만들기 https://www.acmicpc.net/problem/1463 fun main() = with(Scanner(System.`in`)) { val size = nextInt() val count = Array(size + 1) { 0 } count[0] = 0 count[1] = 1 if (size == 1) { return println(0) } count[2] = 1 if (size == 2) { return println(count[size]) } count[3] = 1 if (size == 3) { return println(count[size]) } for (i in 4 until cou..
[백준] 2xn 타일링 https://www.acmicpc.net/problem/11726 fun main() = with(Scanner(System.`in`)) { val size = nextInt() val count = Array(size + 1) { 0 } count[0] = 0 count[1] = 1 if(size == 1){ return println(count[size]) } count[2] = 2 for (i in 3 until count.size) { count[i] = (count[i - 2] + count[i - 1]) % 10007 } println(count[size])}
[백준] 2xn 타일링2 https://www.acmicpc.net/problem/11727 fun main() = with(Scanner(System.`in`)) { val size = nextInt() val count = Array(size + 1) { 0 } count[0] = 0 count[1] = 1 if(size == 1){ println(count[1]) return } count[2] = 3 for (i in 3 until count.size) { count[i] = (count[i - 2] * 2 + count[i - 1]) % 10007 ..