From 9b3dee718f2838414b43abbf8ac48f33e795ea8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Wed, 26 Mar 2025 19:16:26 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=201=EC=B0=A8=EC=8B=9C=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YooGyeongMo/README.md | 2 +- alstjr7437/BFS_DFS/1_alstjr7437.swift | 1 + alstjr7437/README.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 alstjr7437/BFS_DFS/1_alstjr7437.swift diff --git a/YooGyeongMo/README.md b/YooGyeongMo/README.md index 9b095df..c602d98 100644 --- a/YooGyeongMo/README.md +++ b/YooGyeongMo/README.md @@ -2,5 +2,5 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| -| 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35| +| 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/1| --- diff --git a/alstjr7437/BFS_DFS/1_alstjr7437.swift b/alstjr7437/BFS_DFS/1_alstjr7437.swift new file mode 100644 index 0000000..ab88e85 --- /dev/null +++ b/alstjr7437/BFS_DFS/1_alstjr7437.swift @@ -0,0 +1 @@ +let a = 10 \ No newline at end of file diff --git a/alstjr7437/README.md b/alstjr7437/README.md index 9b095df..065fdb2 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -2,5 +2,5 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| -| 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35| +| 1차시 | 2025.03.26 | BFS | [미로 탐색](https://www.acmicpc.net/problem/2178)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/1| --- From 7ca30f9a6b370285bbe465b2df1d65ae628eb144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Sat, 29 Mar 2025 18:11:51 +0900 Subject: [PATCH 2/6] =?UTF-8?q?1=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alstjr7437/BFS_DFS/1_alstjr7437.swift | 1 - ...353\241\234\355\203\220\354\203\211.swift" | 41 +++++++++++++++++++ alstjr7437/README.md | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) delete mode 100644 alstjr7437/BFS_DFS/1_alstjr7437.swift create mode 100644 "alstjr7437/BFS_DFS/\353\257\270\353\241\234\355\203\220\354\203\211.swift" diff --git a/alstjr7437/BFS_DFS/1_alstjr7437.swift b/alstjr7437/BFS_DFS/1_alstjr7437.swift deleted file mode 100644 index ab88e85..0000000 --- a/alstjr7437/BFS_DFS/1_alstjr7437.swift +++ /dev/null @@ -1 +0,0 @@ -let a = 10 \ No newline at end of file diff --git "a/alstjr7437/BFS_DFS/\353\257\270\353\241\234\355\203\220\354\203\211.swift" "b/alstjr7437/BFS_DFS/\353\257\270\353\241\234\355\203\220\354\203\211.swift" new file mode 100644 index 0000000..a7bb7c5 --- /dev/null +++ "b/alstjr7437/BFS_DFS/\353\257\270\353\241\234\355\203\220\354\203\211.swift" @@ -0,0 +1,41 @@ +import Foundation + +// 1. 입력 +let NM = readLine()!.split(separator: " ").map { Int(String($0))! } +var board:[[Int]] = [] +let N = NM[0] - 1 +let M = NM[1] - 1 + +for _ in 0...N { + board.append(readLine()!.map { Int(String($0))! }) +} + +// 2. 필요한 변수 선언 +let dx = [0,0,-1,1] +let dy = [-1,1,0,0] + +var queue:[(Int,Int)] = [(0,0)] +var idx = 0 + +// 3. 미로 탐색(BFS) +board[0][0] = 0 +while idx < queue.count { + let current = queue[idx] + idx += 1 + + if current.0 == N && current.1 == M { break } + for i in 0..<4 { + let nx = current.0 + dx[i] + let ny = current.1 + dy[i] + + if nx > M || nx < 0 || ny > N || ny < 0 { continue } + if board[ny][nx] == 1 { + queue.append((nx,ny)) + board[ny][nx] = board[current.1][current.0] + 1 + } + } +} + +// 4. 결과 출력 +print(board[N][M] + 1) + diff --git a/alstjr7437/README.md b/alstjr7437/README.md index 065fdb2..37d6a81 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -2,5 +2,5 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| -| 1차시 | 2025.03.26 | BFS | [미로 탐색](https://www.acmicpc.net/problem/2178)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/1| +| 1차시 | 2025.03.26 | BFS | [미로 탐색](https://www.acmicpc.net/problem/2178)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/2| --- From 5ace76b0764dc78dd04537c55fbffc28425241ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Tue, 8 Apr 2025 19:48:59 +0900 Subject: [PATCH 3/6] =?UTF-8?q?2=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354\265\234\353\214\200\355\236\231.swift" | 65 +++++++++++++++++++ alstjr7437/README.md | 5 +- 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 "alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" diff --git "a/alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" "b/alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" new file mode 100644 index 0000000..759a4a3 --- /dev/null +++ "b/alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" @@ -0,0 +1,65 @@ +struct Heap { + var elements: [Int] = [] + + mutating func insert(node: Int) { + self.elements.append(node) + + var index = elements.count - 1 + while index > 0 { + let parent = (index - 1) / 2 + + if elements[parent] < elements[index] { + let temp = elements[parent] + elements[parent] = elements[index] + elements[index] = temp + index = parent + } else { + break + } + } + } + + mutating func remove() -> Int? { + guard !elements.isEmpty else { return nil } + if elements.count == 1 { + return elements.removeFirst() + } + + let removeValue = elements[0] + elements[0] = elements.removeLast() + + var index = 0 + while index < elements.count { + let left = index * 2 + 1 + let right = index * 2 + 2 + var current = index + + if left < elements.count && elements[left] > elements[current] { + current = left + } + if right < elements.count && elements[right] > elements[current] { + current = right + } + if current == index { break } + + elements.swapAt(index, current) + index = current + } + + return removeValue + } + +} + +let N = Int(readLine()!)! +var heap = Heap() + +for _ in 0.. Date: Tue, 8 Apr 2025 20:23:28 +0900 Subject: [PATCH 4/6] =?UTF-8?q?refactor:=20swapAt=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Heap/\354\265\234\353\214\200\355\236\231.swift" | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git "a/alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" "b/alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" index 759a4a3..d98a70f 100644 --- "a/alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" +++ "b/alstjr7437/Heap/\354\265\234\353\214\200\355\236\231.swift" @@ -1,5 +1,5 @@ struct Heap { - var elements: [Int] = [] + private var elements: [Int] = [] mutating func insert(node: Int) { self.elements.append(node) @@ -9,9 +9,7 @@ struct Heap { let parent = (index - 1) / 2 if elements[parent] < elements[index] { - let temp = elements[parent] - elements[parent] = elements[index] - elements[index] = temp + elements.swapAt(index, parent) index = parent } else { break @@ -30,6 +28,7 @@ struct Heap { var index = 0 while index < elements.count { + let left = index * 2 + 1 let right = index * 2 + 2 var current = index @@ -61,5 +60,4 @@ for _ in 0.. Date: Wed, 30 Apr 2025 11:43:46 +0900 Subject: [PATCH 5/6] =?UTF-8?q?3=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alstjr7437/README.md | 7 ++++--- .../BOJ_7795.swift" | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 "alstjr7437/\355\210\254\355\217\254\354\235\270\355\204\260/BOJ_7795.swift" diff --git a/alstjr7437/README.md b/alstjr7437/README.md index 6c41c78..a928a20 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -2,6 +2,7 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| -| 1차시 | 2025.03.26 | BFS | [미로 탐색](https://www.acmicpc.net/problem/2178)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/2 -| 2차시 | 2025.04.08 | Heap | [최대힙](https://www.acmicpc.net/problem/11279)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/7|| --- \ No newline at end of file +| 1차시 | 2025.03.26 | BFS | [미로 탐색](https://www.acmicpc.net/problem/2178)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/2| +| 2차시 | 2025.04.08 | Heap | [최대힙](https://www.acmicpc.net/problem/11279)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/7| +| 3차시 | 2025.04.30 | 투포인터 | [최대힙](https://www.acmicpc.net/problem/7795)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/17| +--- \ No newline at end of file diff --git "a/alstjr7437/\355\210\254\355\217\254\354\235\270\355\204\260/BOJ_7795.swift" "b/alstjr7437/\355\210\254\355\217\254\354\235\270\355\204\260/BOJ_7795.swift" new file mode 100644 index 0000000..c4f2ee1 --- /dev/null +++ "b/alstjr7437/\355\210\254\355\217\254\354\235\270\355\204\260/BOJ_7795.swift" @@ -0,0 +1,20 @@ +let T = Int(readLine()!)! + +for _ in 0.. B[j] { + point = j + 1 + result += 1 + } + } + } + print(result) +} From bac1e672d69cd6428326f1e92ab5e14e2fc7c89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Tue, 29 Apr 2025 12:44:28 +0900 Subject: [PATCH 6/6] 2-alstjr7437 (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 1차시 문제 * 1차시 문제 해결 * 2차시 문제 해결 * refactor: swapAt 추가 --- YooGyeongMo/README.md | 3 ++- alstjr7437/README.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/YooGyeongMo/README.md b/YooGyeongMo/README.md index c602d98..fae52c7 100644 --- a/YooGyeongMo/README.md +++ b/YooGyeongMo/README.md @@ -2,5 +2,6 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| -| 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/1| +| 1차시 | 2025.03.30 | 구현 | [유연 근무제](https://school.programmers.co.kr/learn/courses/30/lessons/388351?language=swift)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/5| +| 2차시 | 2025.04.10 | DP | [파이프 옮기기 1](https://www.acmicpc.net/problem/17070)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/9| --- diff --git a/alstjr7437/README.md b/alstjr7437/README.md index a928a20..ace1a9b 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -5,4 +5,4 @@ | 1차시 | 2025.03.26 | BFS | [미로 탐색](https://www.acmicpc.net/problem/2178)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/2| | 2차시 | 2025.04.08 | Heap | [최대힙](https://www.acmicpc.net/problem/11279)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/7| | 3차시 | 2025.04.30 | 투포인터 | [최대힙](https://www.acmicpc.net/problem/7795)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/17| ---- \ No newline at end of file +---