From 9848af2240504517dd2518155d38441cd26d4355 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:49:42 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[BOJ]=20#11660.=20=EA=B5=AC=EA=B0=84=20?= =?UTF-8?q?=ED=95=A9=20=EA=B5=AC=ED=95=98=EA=B8=B0=205=20/=20=EC=8B=A4?= =?UTF-8?q?=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 --- ...1\352\265\254\355\225\230\352\270\2605.py" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "minjeong/PrefixSum/2024-12-10-[\353\260\261\354\244\200]-#11660-\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605.py" diff --git "a/minjeong/PrefixSum/2024-12-10-[\353\260\261\354\244\200]-#11660-\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605.py" "b/minjeong/PrefixSum/2024-12-10-[\353\260\261\354\244\200]-#11660-\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605.py" new file mode 100644 index 00000000..0482cec3 --- /dev/null +++ "b/minjeong/PrefixSum/2024-12-10-[\353\260\261\354\244\200]-#11660-\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605.py" @@ -0,0 +1,33 @@ +import sys +input = sys.stdin.readline + +# 누적합 테이블 계산 +def get_prefix_sum(grid, N): + prefix_sum = [[0] * (N+1) for _ in range(N+1)] + for i in range(1, N+1): + for j in range(1, N+1): + prefix_sum[i][j] = ( + grid[i-1][j-1] + + prefix_sum[i-1][j] + + prefix_sum[i][j-1] + - prefix_sum[i-1][j-1] + ) + return prefix_sum + +# 입력 +N, M = map(int, input().split()) +grid = [list(map(int, input().split())) for _ in range(N)] + +# 누적합 +prefix_sum = get_prefix_sum(grid, N) + +# 범위 합 계산 +for _ in range(M): + x1, y1, x2, y2 = map(int, input().split()) + answer = ( + prefix_sum[x2][y2] + - prefix_sum[x1-1][y2] + - prefix_sum[x2][y1-1] + + prefix_sum[x1-1][y1-1] + ) + print(answer) From 53bd0ab55d36c531cbc16817243ef25fcf04e80c Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Sat, 14 Dec 2024 23:51:12 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[BOJ]=20#10844.=20=EC=89=AC=EC=9A=B4?= =?UTF-8?q?=EA=B3=84=EB=8B=A8=EC=88=98=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 --- ...2\264\352\263\204\353\213\250\354\210\230.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#10844-\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.py" diff --git "a/minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#10844-\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.py" "b/minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#10844-\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.py" new file mode 100644 index 00000000..4802b9dd --- /dev/null +++ "b/minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#10844-\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.py" @@ -0,0 +1,16 @@ +n = int(input()) + +num = [[0]*10 for _ in range(n+1)] +num[0] = [1,1,1,1,1,1,1,1,0] #0행에 들어가는 값들을 계단수의 경우의수로 초기화 + +for i in range(1,n+1): + for j in range(10): #0일때, 9일때, 나머지인 경우를 점화식을 토대로 코드 작성 + if j == 0: + num[i][j] = num[i-1][1] + elif j == 9: + num[i][j] = num[i-1][8] + else: + num[i][j] = num[i-1][j-1] + num[i-1][j] + +answer = sum(num[n]) % 100000000 +print(answer) \ No newline at end of file From 3358a3a831193ab92211837544793f6018826b1d Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Sat, 14 Dec 2024 23:53:02 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[BOJ]=20#1914.=20=ED=95=98=EB=85=B8?= =?UTF-8?q?=EC=9D=B4=ED=83=91=20/=20=EC=8B=A4=EB=B2=841=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 --- ...5\230\353\205\270\354\235\264\355\203\221.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#1914-\355\225\230\353\205\270\354\235\264\355\203\221.py" diff --git "a/minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#1914-\355\225\230\353\205\270\354\235\264\355\203\221.py" "b/minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#1914-\355\225\230\353\205\270\354\235\264\355\203\221.py" new file mode 100644 index 00000000..a22ab883 --- /dev/null +++ "b/minjeong/DynamicProgramming/2024-12-14-[\353\260\261\354\244\200]-#1914-\355\225\230\353\205\270\354\235\264\355\203\221.py" @@ -0,0 +1,16 @@ +# 하노이 함수 +def hanoi_f(one, three, n): + if n == 1: + print(one, three) + return + + hanoi_f(one, 6 - one - three, n - 1) # 1단계 (1->2) + print(one, three) # 2단계 (마지막원반 1->3) + hanoi_f(6 - one - three, three, n - 1) # 3단계 (2->3) + + +# 메인 +n = int(input()) +print(2 ** n - 1) +if n <= 20: + hanoi_f(1, 3, n) \ No newline at end of file From a41e29c99c051cf08424e03fe54c3d7f3ffc5fa4 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Sun, 15 Dec 2024 00:04:48 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[BOJ]=20#14500.=20=ED=85=8C=ED=8A=B8?= =?UTF-8?q?=EB=A1=9C=EB=AF=B8=EB=85=B8=20/=20=EA=B3=A8=EB=93=9C4=20/=2060?= =?UTF-8?q?=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\241\234\353\257\270\353\205\270.py" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "minjeong/Simulation/2024-12-14-[\353\260\261\354\244\200]-#14500-\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.py" diff --git "a/minjeong/Simulation/2024-12-14-[\353\260\261\354\244\200]-#14500-\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.py" "b/minjeong/Simulation/2024-12-14-[\353\260\261\354\244\200]-#14500-\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.py" new file mode 100644 index 00000000..fbe250ce --- /dev/null +++ "b/minjeong/Simulation/2024-12-14-[\353\260\261\354\244\200]-#14500-\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.py" @@ -0,0 +1,57 @@ +n, m = map(int, input().split()) +graph = [list(map(int, input().split())) for _ in range(n)] +visited = [[False] * m for _ in range(n)] + +# 방향 설정 (상, 하, 좌, 우) +dx = [-1, 1, 0, 0] +dy = [0, 0, -1, 1] + +# 최댓값 저장 변수 +max_value = 0 + + +# DFS 탐색 (ㅗ 모양 제외) +def dfs(x, y, count, total): + global max_value + # 테트로미노 4칸 채웠을 경우 + if count == 4: + max_value = max(max_value, total) + return + + # 상하좌우 탐색 + for i in range(4): + nx, ny = x + dx[i], y + dy[i] + # 범위 내에 있고, 방문하지 않은 경우 + if 0 <= nx < n and 0 <= ny < m and not visited[nx][ny]: + visited[nx][ny] = True + dfs(nx, ny, count + 1, total + graph[nx][ny]) + visited[nx][ny] = False # 백트래킹 + + +# ㅗ 모양 탐색 +def check_t_shape(x, y): + global max_value + # 중심 기준 4방향 중 3개를 선택 (ㅗ, ㅜ, ㅏ, ㅓ) + for i in range(4): + total = graph[x][y] + for j in range(3): # 현재 제외한 3방향 탐색 + k = (i + j) % 4 + nx, ny = x + dx[k], y + dy[k] + if 0 <= nx < n and 0 <= ny < m: + total += graph[nx][ny] + else: # 범위를 벗어나면 ㅗ 모양이 성립하지 않음 + break + else: # 모든 3방향 탐색이 유효한 경우 + max_value = max(max_value, total) + + +# 모든 좌표에서 테트로미노 탐색 +for i in range(n): + for j in range(m): + visited[i][j] = True + dfs(i, j, 1, graph[i][j]) # DFS 시작 + visited[i][j] = False + check_t_shape(i, j) # ㅗ 모양 탐색 + +# 결과 출력 +print(max_value)