From ccd4884992c5a7cd9af75a1e3406531101a90256 Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Tue, 29 Jul 2025 19:10:23 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[PGS]=20=EA=B1=B0=EB=A6=AC=EB=91=90?= =?UTF-8?q?=EA=B8=B0=20=ED=99=95=EC=9D=B8=ED=95=98=EA=B8=B0=20/=20Level=20?= =?UTF-8?q?2=20/=2040=EB=B6=84=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25\354\235\270\355\225\230\352\270\260.py" | 41 +++++++++++++++++++ ...25\354\235\270\355\225\230\352\270\260.py" | 41 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 "minjeong/BruteForce/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" create mode 100644 "minjeong/DFSBFS/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" diff --git "a/minjeong/BruteForce/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" "b/minjeong/BruteForce/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" new file mode 100644 index 0000000..d906e11 --- /dev/null +++ "b/minjeong/BruteForce/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" @@ -0,0 +1,41 @@ +def solution(places): + def is_safe(place): + for i in range(5): + for j in range(5): + if place[i][j] != 'P': + continue + + for dx, dy in dirs: + ni, nj = i + dx, j + dy + if not (0 <= ni < 5 and 0 <= nj < 5): + continue + if place[ni][nj] != 'P': + continue + + dist = abs(dx) + abs(dy) + if dist == 1: + return 0 # 거리 1에서 바로 P면 위반 + elif dist == 2: + # 파티션 여부 확인 + if dx == 0: # 수평 + if place[i][j + dy // 2] != 'X': + return 0 + elif dy == 0: # 수직 + if place[i + dx // 2][j] != 'X': + return 0 + else: # 대각선 + if place[i][nj] != 'X' or place[ni][j] != 'X': + return 0 + return 1 + + dirs = [ + (-1, 0), (1, 0), (0, -1), (0, 1), # 거리 1 + (-2, 0), (2, 0), (0, -2), (0, 2), # 일직선 거리 2 + (-1, -1), (-1, 1), (1, -1), (1, 1) # 대각선 거리 2 + ] + + answer = [] + for place in places: + answer.append(is_safe(place)) + + return answer diff --git "a/minjeong/DFSBFS/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" "b/minjeong/DFSBFS/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" new file mode 100644 index 0000000..d906e11 --- /dev/null +++ "b/minjeong/DFSBFS/2025-07-26-[PGS]-\352\261\260\353\246\254\353\221\220\352\270\260\355\231\225\354\235\270\355\225\230\352\270\260.py" @@ -0,0 +1,41 @@ +def solution(places): + def is_safe(place): + for i in range(5): + for j in range(5): + if place[i][j] != 'P': + continue + + for dx, dy in dirs: + ni, nj = i + dx, j + dy + if not (0 <= ni < 5 and 0 <= nj < 5): + continue + if place[ni][nj] != 'P': + continue + + dist = abs(dx) + abs(dy) + if dist == 1: + return 0 # 거리 1에서 바로 P면 위반 + elif dist == 2: + # 파티션 여부 확인 + if dx == 0: # 수평 + if place[i][j + dy // 2] != 'X': + return 0 + elif dy == 0: # 수직 + if place[i + dx // 2][j] != 'X': + return 0 + else: # 대각선 + if place[i][nj] != 'X' or place[ni][j] != 'X': + return 0 + return 1 + + dirs = [ + (-1, 0), (1, 0), (0, -1), (0, 1), # 거리 1 + (-2, 0), (2, 0), (0, -2), (0, 2), # 일직선 거리 2 + (-1, -1), (-1, 1), (1, -1), (1, 1) # 대각선 거리 2 + ] + + answer = [] + for place in places: + answer.append(is_safe(place)) + + return answer From bd65deca9030098c42ce71ed984d278abda003cd Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Wed, 30 Jul 2025 15:29:10 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[BOJ]=20#2468.=20=EC=95=88=EC=A0=84=20?= =?UTF-8?q?=EC=98=81=EC=97=AD=20/=20=EC=8B=A4=EB=B2=841=20/=2050=EB=B6=84?= =?UTF-8?q?=20/=20=ED=9E=8C=ED=8A=B8,=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...10\354\240\204\352\265\254\354\227\255.py" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "minjeong/DFSBFS/2025-08-03-[\353\260\261\354\244\200]-#2458-\354\225\210\354\240\204\352\265\254\354\227\255.py" diff --git "a/minjeong/DFSBFS/2025-08-03-[\353\260\261\354\244\200]-#2458-\354\225\210\354\240\204\352\265\254\354\227\255.py" "b/minjeong/DFSBFS/2025-08-03-[\353\260\261\354\244\200]-#2458-\354\225\210\354\240\204\352\265\254\354\227\255.py" new file mode 100644 index 0000000..5f1e5aa --- /dev/null +++ "b/minjeong/DFSBFS/2025-08-03-[\353\260\261\354\244\200]-#2458-\354\225\210\354\240\204\352\265\254\354\227\255.py" @@ -0,0 +1,42 @@ +import sys +sys.setrecursionlimit(100000) + +input = sys.stdin.readline + +# 방향벡터 +directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] + +def dfs(x, y): + # 깊이 탐색을 하며 안전 영역 탐색 + visited[x][y] = True + for dx, dy in directions: + nx, ny = x + dx, y + dy + if 0 <= nx < N and 0 <= ny < N and \ + not visited[nx][ny] and map[nx][ny] > h: + dfs(nx, ny) + + +N = int(input()) +map = [list(map(int, input().split())) for _ in range(N)] +max_height = 0 + +# 맵 내의 최대값 구하기 +for m in map: + max_height = max(max_height, max(m)) + +answer = 0 + +for h in range(0, max_height + 1): # 물이 잠기지 않는 상황을 고려하여 0부터 시작 + visited = [[False for _ in range(N)] for _ in range(N)] + count = 0 + + for i in range(N): + for j in range(N): + # 아직 방문하지 않았고 h(높이) 이상인 지점이라면 DFS 탐색을 한다. + if not visited[i][j] and map[i][j] > h: + dfs(i, j) + count += 1 # DFS 탐색을 마치면 하나의 안전 영역이므로 count + + answer = max(answer, count) # 안전영역 최대 개수 계산 + +print(answer) \ No newline at end of file From 18176c448ac913ccfa16d14925a907b2564d01c9 Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Mon, 4 Aug 2025 15:20:31 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[BOJ]=20#2644.=20=EC=B4=8C=EC=88=98?= =?UTF-8?q?=EA=B3=84=EC=82=B0=20/=20=EC=8B=A4=EB=B2=842=20/=2030=EB=B6=84?= =?UTF-8?q?=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...14\354\210\230\352\263\204\354\202\260.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "minjeong/DFSBFS/2025-08-04-[\353\260\261\354\244\200]-#2644-\354\264\214\354\210\230\352\263\204\354\202\260.py" diff --git "a/minjeong/DFSBFS/2025-08-04-[\353\260\261\354\244\200]-#2644-\354\264\214\354\210\230\352\263\204\354\202\260.py" "b/minjeong/DFSBFS/2025-08-04-[\353\260\261\354\244\200]-#2644-\354\264\214\354\210\230\352\263\204\354\202\260.py" new file mode 100644 index 0000000..b4d02dd --- /dev/null +++ "b/minjeong/DFSBFS/2025-08-04-[\353\260\261\354\244\200]-#2644-\354\264\214\354\210\230\352\263\204\354\202\260.py" @@ -0,0 +1,31 @@ +import sys +input = sys.stdin.readline + +def dfs(start, cnt): + global chonsu + if start == y: + chonsu = cnt + return + + for i in graph[start]: + if not visited[i]: + visited[i] = True + dfs(i, cnt + 1) + visited[i] = False + + +n = int(input()) # 전체 사람 개수 +x, y = map(int, input().split()) +graph = [[] for _ in range(n+1)] +visited = [False for _ in range(n + 1)] +chonsu = -1 # 정답으로 반환할 촌수 + +m = int(input()) # 부모 자식들간의 관계 개수 +for _ in range(m): + a, b = map(int, input().split()) + graph[a].append(b) + graph[b].append(a) + +visited[x] = True +dfs(x, 0) +print(chonsu) From 8dbef07bf704174949154cbf9a7650fbab8f9ed4 Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Tue, 5 Aug 2025 16:09:54 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[BOJ]=20#5014.=20=EC=8A=A4=ED=83=80?= =?UTF-8?q?=ED=8A=B8=EB=A7=81=ED=81=AC=20/=20=EC=8B=A4=EB=B2=841=20/=2040?= =?UTF-8?q?=EB=B6=84=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...00\355\212\270\353\247\201\355\201\254.py" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "minjeong/DFSBFS/2025-08-05-[\353\260\261\354\244\200]-#5014-\354\212\244\355\203\200\355\212\270\353\247\201\355\201\254.py" diff --git "a/minjeong/DFSBFS/2025-08-05-[\353\260\261\354\244\200]-#5014-\354\212\244\355\203\200\355\212\270\353\247\201\355\201\254.py" "b/minjeong/DFSBFS/2025-08-05-[\353\260\261\354\244\200]-#5014-\354\212\244\355\203\200\355\212\270\353\247\201\355\201\254.py" new file mode 100644 index 0000000..713ce4f --- /dev/null +++ "b/minjeong/DFSBFS/2025-08-05-[\353\260\261\354\244\200]-#5014-\354\212\244\355\203\200\355\212\270\353\247\201\355\201\254.py" @@ -0,0 +1,46 @@ +import sys +from collections import deque + +input = sys.stdin.readline + +# 총 층수 F, 현재 층 S, 목표 층 G, 위 버튼 U, 아래 버튼 D +F, S, G, U, D = map(int, input().split()) + + +def bfs(): + if S == G: # 강호가 이미 도착해있다면 0번 클릭 + return 0 + + visited = [False for _ in range(F + 1)] + queue = deque([(S, 1)]) # (현재 층, 버튼 클릭 횟수) + visited[S] = True + + while queue: + x, cnt = queue.popleft() + + # 위로 이동 + nx = x + U + if nx <= F and not visited[nx]: + if nx == G: # 목표층 도착 + return cnt + queue.append((nx, cnt + 1)) + visited[nx] = True # 방문여부 표시 꼭 넣어주기 + + # 아래로 이동 + nx = x - D + if nx > 0 and not visited[nx]: + if nx == G: # 목표층 도착 + return cnt + queue.append((nx, cnt + 1)) + visited[nx] = True + + # 목표층에 도달하지 못한 경우 + return -1 + + +# BFS 탐색 +answer = bfs() +if answer == -1: + print("use the stairs") +else: + print(answer) \ No newline at end of file From 6d349e7c09e0c5e3b8c44614a085842d2ce41282 Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Wed, 6 Aug 2025 16:54:53 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[BOJ]=20#1158.=20=EC=9A=94=EC=84=B8?= =?UTF-8?q?=ED=91=B8=EC=8A=A4=20=EB=AC=B8=EC=A0=9C=20/=20=EC=8B=A4?= =?UTF-8?q?=EB=B2=844=20/=2010=EB=B6=84=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\354\212\244\353\254\270\354\240\234.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" diff --git "a/minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" "b/minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" new file mode 100644 index 0000000..1f581e9 --- /dev/null +++ "b/minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" @@ -0,0 +1,19 @@ +import sys +from collections import deque +input = sys.stdin.readline + +N, K = map(int, input().split()) +# 1번부터 N번까지 사람을 큐에 넣기 +people = deque([i+1 for i in range(N)]) +answer = [] # 제거된 순서를 저장할 리스트 + +while people: + # K-1번 앞의 원소를 빼서 뒤로 보냄 (원형 이동) + for _ in range(K-1): + cur = people.popleft() + people.append(cur) + # K번째에서 제거 + answer.append(people.popleft()) + +# 정답 출력 +print("<" + ", ".join(map(str, answer)) + ">") \ No newline at end of file From 796dd87771dbcb61ec9dfbe5e439e0a370489077 Mon Sep 17 00:00:00 2001 From: Minjeong Kim Date: Fri, 8 Aug 2025 18:04:18 +0900 Subject: [PATCH 6/6] =?UTF-8?q?refact:=20=EC=BD=94=EB=93=9C=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B4=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" "b/minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" index 1f581e9..8884364 100644 --- "a/minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" +++ "b/minjeong/Stack, Queue, Priority Queue/2025-08-06-[\353\260\261\354\244\200]-#1158-\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" @@ -8,7 +8,7 @@ answer = [] # 제거된 순서를 저장할 리스트 while people: - # K-1번 앞의 원소를 빼서 뒤로 보냄 (원형 이동) + # K-1번 앞의 원소를 빼서 뒤로 보냄 (원형 이동) for _ in range(K-1): cur = people.popleft() people.append(cur)