From ccd1946180f33080c5e92ea87b0205dafcefd2f5 Mon Sep 17 00:00:00 2001 From: JangHongJoon Date: Wed, 27 Mar 2024 17:56:39 +0900 Subject: [PATCH 1/2] 2024.03.27 solved --- wkdghdwns199/README.md | 1 + .../ACM-24416.py" | 25 +++++++++++++++++++ .../ACM-9184.py" | 25 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 "wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-24416.py" create mode 100644 "wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-9184.py" diff --git a/wkdghdwns199/README.md b/wkdghdwns199/README.md index 60327f7..73b4d7f 100644 --- a/wkdghdwns199/README.md +++ b/wkdghdwns199/README.md @@ -17,4 +17,5 @@ | 13차시 | 2024.03.09 | DP | 정수 삼각형 | 2024.03.09 | | 14차시 | 2024.03.13 | 집합과 맵 | 영단어 암기는 괴로워 | 2024.03.13 | | 15차시 | 2024.03.20 | 우선순위 큐 | 절댓값 힙 | 2024.03.20 | +| 17차시 | 2024.03.27 | DP | 신나는 함수 실행 | 2024.03.27 | diff --git "a/wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-24416.py" "b/wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-24416.py" new file mode 100644 index 0000000..aa59f54 --- /dev/null +++ "b/wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-24416.py" @@ -0,0 +1,25 @@ +import sys +input = sys.stdin.readline + +def fib(n) : + global countFib + if n==1 or n==2: + countFib += 1 + return 1 + else : + return fib(n-1) + fib(n-2) + +def fibo(n): + global countFibo + f = [0 for _ in range(n+1)] + f[1] = f[2] = 1 + for idx in range(3, n+1): + countFibo+=1 + f[idx] = f[idx-1] + f[idx-2] + return f[n] + +N = int(input()) +countFib = countFibo = 0 +fib(N) +fibo(N) +print(countFib, countFibo) \ No newline at end of file diff --git "a/wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-9184.py" "b/wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-9184.py" new file mode 100644 index 0000000..c421a18 --- /dev/null +++ "b/wkdghdwns199/\353\217\231\354\240\201_\352\263\204\355\232\215\353\262\225_1/ACM-9184.py" @@ -0,0 +1,25 @@ +import sys +input = sys.stdin.readline + +def w(a,b,c): + if a<=0 or b<=0 or c<=0 : + return 1 + if a>20 or b>20 or c>20: + return w(20,20,20) + if dp[a][b][c] : + return dp[a][b][c] + if a Date: Mon, 1 Apr 2024 21:51:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ACM-16234.py" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "wkdghdwns199/\353\246\254\353\267\260\355\222\200\354\235\264/ACM-16234.py" diff --git "a/wkdghdwns199/\353\246\254\353\267\260\355\222\200\354\235\264/ACM-16234.py" "b/wkdghdwns199/\353\246\254\353\267\260\355\222\200\354\235\264/ACM-16234.py" new file mode 100644 index 0000000..07a9c50 --- /dev/null +++ "b/wkdghdwns199/\353\246\254\353\267\260\355\222\200\354\235\264/ACM-16234.py" @@ -0,0 +1,46 @@ +import sys +from collections import deque +input = sys.stdin.readline +N,L,R = map(int, input().split()) +country = [list(map(int, input().split())) for _ in range(N)] +q = deque() +#연합이 될 수 있을지 확인 후 연랍이 되면 저장 +dx = [1,0,-1,0] +dy = [0,1,0,-1] + +def bfs(x,y): + q.append((x,y)) + union=[] + union.append((x,y)) + while q: + a,b = q.popleft() + for i in range(4): + na = a + dx[i] + nb = b + dy[i] + if na >= N or nb>= N or nb<0 or na <0 or visited[na][nb]==1: + continue + if R>=abs(country[a][b]-country[na][nb]) >= L: + visited[na][nb] = 1 + q.append((na,nb)) + union.append((na,nb)) + if len(union)<=1: + return 0 + result=sum(country[a][b] for a,b in union) // len(union) + for a,b in union: + country[a][b] = result + + return 1 +day=0 + +while True : + stop = 0 + visited = [[0]*N for _ in range(N)] + for i in range(N): + for j in range(N): + if visited[i][j] == 0: + visited[i][j] = 1 + stop += bfs(i,j) + if stop ==0: + break + day+=1 +print(day) \ No newline at end of file