From 7a65b0276d2f3c5f2b7b94114ce7cb50231eba67 Mon Sep 17 00:00:00 2001 From: H0ngJu Date: Sat, 18 May 2024 21:29:01 +0900 Subject: [PATCH 1/4] 2024-05-18 --- ...4\353\246\254 \352\262\214\354\236\204.py" | 49 +++++++++++++++++++ H0ngJu/README.md | 1 + 2 files changed, 50 insertions(+) create mode 100644 "H0ngJu/BFS/\353\261\200\352\263\274 \354\202\254\353\213\244\353\246\254 \352\262\214\354\236\204.py" diff --git "a/H0ngJu/BFS/\353\261\200\352\263\274 \354\202\254\353\213\244\353\246\254 \352\262\214\354\236\204.py" "b/H0ngJu/BFS/\353\261\200\352\263\274 \354\202\254\353\213\244\353\246\254 \352\262\214\354\236\204.py" new file mode 100644 index 00000000..3e159378 --- /dev/null +++ "b/H0ngJu/BFS/\353\261\200\352\263\274 \354\202\254\353\213\244\353\246\254 \352\262\214\354\236\204.py" @@ -0,0 +1,49 @@ +import sys +from collections import deque + +def input(): return sys.stdin.readline().rstrip() + +N, M = map(int, input().split()) +ladder = [list(map(int, input().split())) for _ in range(N)] +snake = [list(map(int, input().split())) for _ in range(M)] +game = [i for i in range(1,101)] +visited = [0 for _ in range(100)] +q = deque() + +q.append((1,0)) +visited[0] = 1 + +while q: + cur, dice = q.popleft() + if cur == 100: + print(dice) + break + for i in range(1, 7): + check = 0 + + if cur + i > 100: continue + + # 사다리 갈 수 있는지 검사 + for l, n in ladder: + if cur + i == l: + if visited[n-1] == 0: + q.append((n, dice+1)) + visited[n-1] = 1 + check = 1 + break + + if check: continue + # 뱀 있는지 검사 + for s, n in snake: + if cur + i == s: + if visited[n-1] == 0: + q.append((n, dice+1)) + visited[n-1] = 1 + check = 1 + break + + if check: continue + # 그 외 + if visited[cur + i-1] == 0: + q.append((cur + i, dice + 1)) + visited[cur + i-1] = 1 \ No newline at end of file diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 517e2252..2f4207eb 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -17,5 +17,6 @@ | 13차시 | 2024.05.06 | 완전탐색 | [리모컨](https://www.acmicpc.net/problem/1107) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/181 | | 14차시 | 2024.05.09 | DFS | [치킨배달](https://www.acmicpc.net/problem/15686) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/183 | | 15차시 | 2024.05.14 | 그리디 | [A와 B](https://www.acmicpc.net/problem/12904) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/188 | +| 16차시 | 2024.05.14 | BFS | [뱀과 사다리 게임](https://www.acmicpc.net/problem/16928) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/191 | --- From 3553f9c1b5c68d1ff337c7899d59d2f0402be60e Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sun, 19 May 2024 00:38:40 +0900 Subject: [PATCH 2/4] 2024-05-18 update README.md --- SeongHoonC/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SeongHoonC/README.md b/SeongHoonC/README.md index 4d2959be..97f7017b 100644 --- a/SeongHoonC/README.md +++ b/SeongHoonC/README.md @@ -24,5 +24,6 @@ | 20차시 | 2024.04.07 | DP | |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/75 | | 21차시 | 2024.04.11 | DP | RGB거리 |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/77 | | 22차시 | 2024.05.01 | DP | 가장 긴 증가하는 부분 수열 |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/80 | -| 23차시 | 2024.05.14 | ??? | 소수의 연속합 |https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/186 | +| 23차시 | 2024.05.14 | 소수 | 소수의 연속합 |https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/186 | +| 24차시 | 2024.05.18| ??? | n-queen |https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/192 | --- From ea14deedca2bab3d7546e3031c6a40136651c952 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sun, 19 May 2024 20:03:03 +0900 Subject: [PATCH 3/4] 2024-05-19 solved --- SeongHoonC/dfs/nqeen.kt | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 SeongHoonC/dfs/nqeen.kt diff --git a/SeongHoonC/dfs/nqeen.kt b/SeongHoonC/dfs/nqeen.kt new file mode 100644 index 00000000..aa11ddf5 --- /dev/null +++ b/SeongHoonC/dfs/nqeen.kt @@ -0,0 +1,41 @@ +import java.io.BufferedReader +import java.io.InputStreamReader + +var answer = 0 +var n: Int = 0 +lateinit var board: IntArray +fun main() { + val br = BufferedReader(InputStreamReader(System.`in`)) + n = br.readLine().toInt() + board = IntArray(n) + backTracking(0) + println(answer) +} + +private fun backTracking(row: Int) { + // row 가 증가하다가 n 이랑 같아지면 정답 +1 + if (row == n) { + answer++ + return + } + // row 일 때 각 열에 놓을 경우의 수 + for (col in 0 until n) { + board[row] = col + // 놓을 수 있다면 다음 행 + if (check(row)) backTracking(row + 1) + } +} + +private fun check(row: Int): Boolean { + for (i in 0 until row) { + // 행이 같거나 + if (board[row] == board[i]) { + return false + } + // 대각선 + if (row - i == kotlin.math.abs(board[row] - board[i])) { + return false + } + } + return true +} From 982369ad42060181accc32311a12a446273300aa Mon Sep 17 00:00:00 2001 From: vrexpert Date: Wed, 22 May 2024 16:08:33 +0900 Subject: [PATCH 4/4] =?UTF-8?q?2024-05-18=20=EB=AC=B8=EC=A0=9C=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SeongHoonC/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SeongHoonC/README.md b/SeongHoonC/README.md index 97f7017b..e8dbcae8 100644 --- a/SeongHoonC/README.md +++ b/SeongHoonC/README.md @@ -25,5 +25,5 @@ | 21차시 | 2024.04.11 | DP | RGB거리 |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/77 | | 22차시 | 2024.05.01 | DP | 가장 긴 증가하는 부분 수열 |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/80 | | 23차시 | 2024.05.14 | 소수 | 소수의 연속합 |https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/186 | -| 24차시 | 2024.05.18| ??? | n-queen |https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/192 | +| 24차시 | 2024.05.18| 백트래킹 | n-queen |https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/192 | ---