From 6d7a8eaba7d20a2cee56c92ff5184a95be24cc77 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Sun, 27 Apr 2025 20:21:40 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[BOJ]=20#2110.=20=EA=B3=B5=EC=9C=A0?= =?UTF-8?q?=EA=B8=B0=20=EC=84=A4=EC=B9=98=20/=20=EA=B3=A8=EB=93=9C4=20/=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...40\352\270\260\354\204\244\354\271\230.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "minjeong/BinarySearch/2025-04-28-[\353\260\261\354\244\200]-#2110-\352\263\265\354\234\240\352\270\260\354\204\244\354\271\230.py" diff --git "a/minjeong/BinarySearch/2025-04-28-[\353\260\261\354\244\200]-#2110-\352\263\265\354\234\240\352\270\260\354\204\244\354\271\230.py" "b/minjeong/BinarySearch/2025-04-28-[\353\260\261\354\244\200]-#2110-\352\263\265\354\234\240\352\270\260\354\204\244\354\271\230.py" new file mode 100644 index 00000000..f43d35a7 --- /dev/null +++ "b/minjeong/BinarySearch/2025-04-28-[\353\260\261\354\244\200]-#2110-\352\263\265\354\234\240\352\270\260\354\204\244\354\271\230.py" @@ -0,0 +1,27 @@ +import sys +input = sys.stdin.readline + +N, C = map(int, input().split()) # N: 집 개수, C: 공유기 개수 +houses = [int(input()) for _ in range(N)] # 집 좌표 리스트 +houses.sort() + +left = 1 # 최소 거리 +right = houses[N-1] - houses[0] +result = 0 + +while left <= right: + mid = (left + right) // 2 # 현재 설정된 거리 + cnt = 1 # 공유기 최소 1대 + check = houses[0] + + for i in range(N): + if houses[i] - check >= mid: # 현재 설정된 거리 이상이면 공유기 개수 늘리기 + cnt += 1 + check = houses[i] + if cnt >= C: # 공유기 설치 수가 C 이상이면, 공유기간 거리 늘리기 + left = mid + 1 + result = max(result, mid) + else: # 공유기 설치 수가 C보다 미만이면, 공유기간 거리 줄이기 + right = mid - 1 + +print(result) \ No newline at end of file From 884e23703ed030dec9cdd58da7e4de206983ac12 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Thu, 1 May 2025 20:33:37 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[BOJ]=20#1654.=20=EB=9E=9C=EC=84=A0=20?= =?UTF-8?q?=EC=9E=90=EB=A5=B4=EA=B8=B0=20/=20=EC=8B=A4=EB=B2=842=20/=2060?= =?UTF-8?q?=EB=B6=84=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 --- ...40\354\236\220\353\245\264\352\270\260.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "minjeong/BinarySearch/2025-05-01-[\353\260\261\354\244\200]-#1654-\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" diff --git "a/minjeong/BinarySearch/2025-05-01-[\353\260\261\354\244\200]-#1654-\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" "b/minjeong/BinarySearch/2025-05-01-[\353\260\261\354\244\200]-#1654-\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 00000000..db41e324 --- /dev/null +++ "b/minjeong/BinarySearch/2025-05-01-[\353\260\261\354\244\200]-#1654-\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,19 @@ +import sys +input = sys.stdin.readline + +K, N = map(int, input().split()) # K: 기존 랜선 수, N: 필요한 랜선 수 +arr = [int(input()) for _ in range(K)] + +start = 1 +end = max(arr) + +while start <= end: + mid = (start + end) // 2 # 현재 시도할 랜선 길이 + cnt = sum(x // mid for x in arr) # 해당 길이로 만들 수 있는 랜선 개수 + + if cnt >= N: + start = mid + 1 # 더 길게 잘라도 됨 + else: + end = mid - 1 # 너무 길어서 N개 못 만듦 + +print(end) # 조건을 만족하는 최대 길이 From 91b250624a5755ae0d6db7365ada3900e11c5b98 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Fri, 2 May 2025 20:43:34 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[BOJ]=20#2178.=20=EB=AF=B8=EB=A1=9C?= =?UTF-8?q?=ED=83=90=EC=83=89=20/=20=EC=8B=A4=EB=B2=841=20/=2055=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 --- ...70\353\241\234\355\203\220\354\203\211.py" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2178-\353\257\270\353\241\234\355\203\220\354\203\211.py" diff --git "a/minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2178-\353\257\270\353\241\234\355\203\220\354\203\211.py" "b/minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2178-\353\257\270\353\241\234\355\203\220\354\203\211.py" new file mode 100644 index 00000000..884d8e0d --- /dev/null +++ "b/minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2178-\353\257\270\353\241\234\355\203\220\354\203\211.py" @@ -0,0 +1,39 @@ +import sys +from collections import deque +input = sys.stdin.readline + +# 입력 처리 +N, M = map(int, input().split()) +graph = [list(map(int, input().strip())) for _ in range(N)] + +def bfs(x, y): + # 방향: 상, 하, 좌, 우 + dx = [-1, 1, 0, 0] + dy = [0, 0, -1, 1] + + queue = deque() + queue.append((x, y)) + + while queue: + x, y = queue.popleft() + + for i in range(4): + nx = x + dx[i] + ny = y + dy[i] + + # 범위 벗어나면 무시 + if nx < 0 or nx >= N or ny < 0 or ny >= M: + continue + + # 벽이면 무시 + if graph[nx][ny] == 0: + continue + + # 이동 가능한 칸이면 거리 갱신 후 방문 처리 + if graph[nx][ny] == 1: + graph[nx][ny] = graph[x][y] + 1 + queue.append((nx, ny)) + + return graph[N-1][M-1] + +print(bfs(0, 0)) From 4f6803b161e23fae7fa22a909ff8648a60c7ea9c Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Fri, 2 May 2025 20:54:26 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[BOJ]=20#2667.=20=EB=8B=A8=EC=A7=80?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EB=B6=99=EC=9D=B4=EA=B8=B0=20/=20?= =?UTF-8?q?=EC=8B=A4=EB=B2=841=20/=2060=EB=B6=84=20/=20=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\353\266\231\354\235\264\352\270\260.py" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2667-\353\213\250\354\247\200\353\262\210\355\230\270\353\266\231\354\235\264\352\270\260.py" diff --git "a/minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2667-\353\213\250\354\247\200\353\262\210\355\230\270\353\266\231\354\235\264\352\270\260.py" "b/minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2667-\353\213\250\354\247\200\353\262\210\355\230\270\353\266\231\354\235\264\352\270\260.py" new file mode 100644 index 00000000..0ddcb36d --- /dev/null +++ "b/minjeong/DFSBFS/2025-05-02-[\353\260\261\354\244\200]-#2667-\353\213\250\354\247\200\353\262\210\355\230\270\353\266\231\354\235\264\352\270\260.py" @@ -0,0 +1,43 @@ +import sys +from collections import deque +input = sys.stdin.readline + +# 방향 벡터: 상, 하, 좌, 우 +dx = [-1, 1, 0, 0] +dy = [0, 0, -1, 1] + +def bfs(start_x, start_y): + queue = deque() + queue.append((start_x, start_y)) + graph[start_x][start_y] = 0 # 방문 처리 + house_count = 1 # 단지 내 집 수 + + while queue: + x, y = queue.popleft() + for i in range(4): # 상하좌우 탐색 + nx, ny = x + dx[i], y + dy[i] + + # 좌표가 유효한지 확인 + if 0 <= nx < n and 0 <= ny < n and graph[nx][ny] == 1: + graph[nx][ny] = 0 # 방문 처리 + queue.append((nx, ny)) + house_count += 1 + return house_count + +# 입력 +n = int(input()) +graph = [list(map(int, input().strip())) for _ in range(n)] + +result = [] + +# 모든 좌표 순회하며 BFS 수행 +for i in range(n): + for j in range(n): + if graph[i][j] == 1: + result.append(bfs(i, j)) + +# 결과 출력 +result.sort() +print(len(result)) +for count in result: + print(count)