From d36c0a57da17ab4749dfbfab3346b28e634f5abf Mon Sep 17 00:00:00 2001 From: ssongjay Date: Thu, 24 Nov 2022 19:49:49 +0900 Subject: [PATCH 1/7] AC / 1h 7m --- week2/ssong/ssong_b5430.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 week2/ssong/ssong_b5430.py diff --git a/week2/ssong/ssong_b5430.py b/week2/ssong/ssong_b5430.py new file mode 100644 index 0000000..e5eac63 --- /dev/null +++ b/week2/ssong/ssong_b5430.py @@ -0,0 +1,32 @@ +# AC + +import sys +from collections import deque + +T = int(sys.stdin.readline().rstrip()) +for _ in range(T): + flag = 1; + p = sys.stdin.readline().rstrip() + n = int(sys.stdin.readline().rstrip()) + num_array = deque(sys.stdin.readline().strip()[1:-1].split(',')) + if n == 0: + num_array = deque() + for i in p: + if i == 'R': + flag *= (-1) + elif i == 'D': + if len(num_array) == 0: + print("error") + flag = 0 + break + else: + if flag == 1: + num_array.popleft() + elif flag == -1: + num_array.pop() + if flag == -1: + num_array.reverse() + print("[" + ",".join(num_array) + "]") + elif flag == 1: + print("[" + ",".join(num_array) + "]") + From 7450be091f8919bcab5f18cef8cd00504aa49187 Mon Sep 17 00:00:00 2001 From: ssongjay Date: Thu, 24 Nov 2022 19:50:14 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=EC=A0=88=EB=8C=93=EA=B0=92=20=ED=9E=99=20/?= =?UTF-8?q?=2027m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week2/ssong/ssong_b11286.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 week2/ssong/ssong_b11286.py diff --git a/week2/ssong/ssong_b11286.py b/week2/ssong/ssong_b11286.py new file mode 100644 index 0000000..99964d7 --- /dev/null +++ b/week2/ssong/ssong_b11286.py @@ -0,0 +1,17 @@ +# 절댓값 힙 + +import sys +import heapq + +N = int(sys.stdin.readline().rstrip()) +queue = [] + +for i in range(N): + x = int(sys.stdin.readline().rstrip()) + if x != 0: + heapq.heappush(queue, (abs(x), x)) + else: + if not queue: + print(0) + else: + print(heapq.heappop(queue)[1]) From 3f2b6c85935d6192f6874685baedf4885995d38c Mon Sep 17 00:00:00 2001 From: ssongjay Date: Sat, 26 Nov 2022 14:35:09 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=ED=94=BC=EB=B3=B4=EB=82=98=EC=B9=98=20?= =?UTF-8?q?=EC=88=98=205=20/=203m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week3/ssong/ssong_b10870.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 week3/ssong/ssong_b10870.py diff --git a/week3/ssong/ssong_b10870.py b/week3/ssong/ssong_b10870.py new file mode 100644 index 0000000..ce45c7d --- /dev/null +++ b/week3/ssong/ssong_b10870.py @@ -0,0 +1,15 @@ +# 피보나치 수 5 + +import sys + +n = int(sys.stdin.readline().rstrip()) + +def fibo(n): + if n == 0: + return 0 + elif n == 1: + return 1 + else: + return (fibo(n - 1) + fibo(n - 2)) + +print(fibo(n)) \ No newline at end of file From 4d0214ad16582e0419a1b4bec0d638d661c729a6 Mon Sep 17 00:00:00 2001 From: ssongjay Date: Sat, 26 Nov 2022 15:42:43 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=EC=9E=AC=EA=B7=80=ED=95=A8=EC=88=98?= =?UTF-8?q?=EA=B0=80=20=EB=AD=94=EA=B0=80=EC=9A=94=3F=20/=2024m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week3/ssong/ssong_b17478.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 week3/ssong/ssong_b17478.py diff --git a/week3/ssong/ssong_b17478.py b/week3/ssong/ssong_b17478.py new file mode 100644 index 0000000..2dbea70 --- /dev/null +++ b/week3/ssong/ssong_b17478.py @@ -0,0 +1,37 @@ +# 재귀함수가 뭔가요? + +import sys + +N = int(sys.stdin.readline().rstrip()) + +print("어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.") + +def last_print(index): + print_dot(index) + print("\"재귀함수가 뭔가요?\"") + print_dot(index) + print("\"재귀함수는 자기 자신을 호출하는 함수라네\"") + print_dot(index) + print("라고 답변하였지.") + +def print_dot(index): + for _ in range(index): + print("____", end='') + +def recursive(N, index): + if index >= N: + last_print(index) + else: + print_dot(index) + print("\"재귀함수가 뭔가요?\"") + print_dot(index) + print("\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.") + print_dot(index) + print("마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.") + print_dot(index) + print("그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어.\"") + recursive(N, index + 1) + print_dot(index) + print("라고 답변하였지.") + +recursive(N, 0); From 09cdc39b4ed87945d80340e6d3db1b5538da6f3f Mon Sep 17 00:00:00 2001 From: ssongjay Date: Sun, 27 Nov 2022 11:57:12 +0900 Subject: [PATCH 5/7] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed57901..916c43b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ | 주차 | 카테고리 | 문제 번호 | 참여자 | | ------ | --------------------------------- | ---------------------------------------------------------------------------------- | -------------------------------- | | 1주차 | 수학 | [Week1](https://www.acmicpc.net/workbook/view/8997) | 최옐인😎 ❤️ 변영화😆 ❤️ 송인제😋 | -| 2주차 | 자료구조 (해시, 스택, 큐, 덱, 힙) | [Week2](https://www.acmicpc.net/workbook/view/8999) | 최옐인😊 | +| 2주차 | 자료구조 (해시, 스택, 큐, 덱, 힙) | [Week2](https://www.acmicpc.net/workbook/view/8999) | 최옐인😊 송인제😆 | | 3주차 | 재귀, 정렬 | [Week3](https://www.acmicpc.net/workbook/view/9000) | 최옐인😎 | | 4주차 | 다이나믹 프로그래밍 (DP) | [Week4](https://www.acmicpc.net/workbook/view/9001) | | | 5주차 | 그래프 - 기초 DFS와 BFS | [Week5](https://www.acmicpc.net/workbook/view/9003) | | From 30f984b9e661e9ef06e0cffc8fc25017b8c89af8 Mon Sep 17 00:00:00 2001 From: ssongjay Date: Sun, 27 Nov 2022 14:57:31 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=ED=95=98=EB=85=B8=EC=9D=B4=20=ED=83=91=20/?= =?UTF-8?q?=201h=202m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week3/ssong/ssong_b1914.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 week3/ssong/ssong_b1914.py diff --git a/week3/ssong/ssong_b1914.py b/week3/ssong/ssong_b1914.py new file mode 100644 index 0000000..1de2c98 --- /dev/null +++ b/week3/ssong/ssong_b1914.py @@ -0,0 +1,20 @@ +# 하노이 탑 + +import sys +# 원판의 개수 N +N = int(sys.stdin.readline().rstrip()) + +# N 홀수일 때 3에 먼저 올려야함 +# N 짝수일 때 2에 먼저 올려야함 + +def hanoi(N, a, b, c): + if N == 1: + print(a, c, sep = " ") + else: + hanoi(N - 1, a, c, b) + hanoi(1, a, b, c) + hanoi(N - 1, b, a, c) + +print(2**N - 1) +if(N <= 20): + hanoi(N, 1, 2, 3) From 530f3d27197f874d2ac3ab06f4f170d457c7c3e9 Mon Sep 17 00:00:00 2001 From: ssongjay Date: Sun, 27 Nov 2022 15:01:32 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=ED=95=98=EB=85=B8=EC=9D=B4=20=ED=83=91=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EC=88=9C=EC=84=9C=20/=201m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week3/ssong/ssong_b11729.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 week3/ssong/ssong_b11729.py diff --git a/week3/ssong/ssong_b11729.py b/week3/ssong/ssong_b11729.py new file mode 100644 index 0000000..4e04885 --- /dev/null +++ b/week3/ssong/ssong_b11729.py @@ -0,0 +1,20 @@ +# 하노이 탑 이동 순서 + +import sys +# 원판의 개수 N +N = int(sys.stdin.readline().rstrip()) + +# N 홀수일 때 3에 먼저 올려야함 +# N 짝수일 때 2에 먼저 올려야함 + +def hanoi(N, a, b, c): + if N == 1: + print(a, c, sep = " ") + else: + hanoi(N - 1, a, c, b) + hanoi(1, a, b, c) + hanoi(N - 1, b, a, c) + +print(2**N - 1) +if(N <= 20): + hanoi(N, 1, 2, 3)