From b83566605d8db01ee197d6fda4b9ec5cdb5adf33 Mon Sep 17 00:00:00 2001 From: Han Ga Eun Date: Mon, 23 Sep 2024 23:59:12 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=ED=95=9C=EA=B0=80=EC=9D=80=2010808?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\355\225\234\352\260\200\354\235\200/Q10808.py" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "\355\225\234\352\260\200\354\235\200/Q10808.py" diff --git "a/\355\225\234\352\260\200\354\235\200/Q10808.py" "b/\355\225\234\352\260\200\354\235\200/Q10808.py" new file mode 100644 index 0000000..098c057 --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/Q10808.py" @@ -0,0 +1,8 @@ +abc = [0]*26 +s = input() + +for i in s: + abc[ord(i)-ord('a')] += 1 + +for i in abc: + print(i) From 271e63b3fd8c8f3e95b0d429cbc539b88397d8aa Mon Sep 17 00:00:00 2001 From: Han Ga Eun Date: Wed, 25 Sep 2024 03:39:55 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=ED=95=9C=EA=B0=80=EC=9D=80=201406?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Q1406.py" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\355\225\234\352\260\200\354\235\200/Q1406.py" diff --git "a/\355\225\234\352\260\200\354\235\200/Q1406.py" "b/\355\225\234\352\260\200\354\235\200/Q1406.py" new file mode 100644 index 0000000..e199eda --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/Q1406.py" @@ -0,0 +1,23 @@ +from sys import stdin + +left = list(input()) +right = [] + +order = int(input()) + +for i in range(order): + key = list(stdin.readline().split()) + + if key[0] == 'L' and left: + right.append(left.pop()) + + elif key[0] == 'D' and right: + left.append(right.pop()) + + elif key[0] == 'B' and left: + left.pop() + + elif key[0] == 'P': + left.append(key[1]) + +print(''.join(left) + ''.join(reversed(right))) From 5af0e4ff5a16739cccd42534aa8e53a5fbda64bb Mon Sep 17 00:00:00 2001 From: Han Ga Eun Date: Tue, 1 Oct 2024 08:50:43 +0900 Subject: [PATCH 3/7] =?UTF-8?q?10828=20=EC=8A=A4=ED=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../B10828.py" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\355\225\234\352\260\200\354\235\200/B10828.py" diff --git "a/\355\225\234\352\260\200\354\235\200/B10828.py" "b/\355\225\234\352\260\200\354\235\200/B10828.py" new file mode 100644 index 0000000..2e42fc0 --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/B10828.py" @@ -0,0 +1,23 @@ +import sys + +stack = [] +n = int(sys.stdin.readline()) +for _ in range(n): + command = list(sys.stdin.readline().split()) + if command[0] == "push" : + stack.append(command[1]) + + elif command[0] == "pop" : + if(stack) : print(stack.pop()) + else : print(-1) + + elif command[0] == "size": + print(len(stack)) + + elif command[0] == "empty": + if(stack): print(0) + else : print(1) + + else : + if(stack) : print(stack[-1]) + else : print(-1) From 5b2d34f58218d9c5f504ec8fe1ba06ad8d9f9001 Mon Sep 17 00:00:00 2001 From: Han Ga Eun Date: Tue, 1 Oct 2024 09:07:51 +0900 Subject: [PATCH 4/7] =?UTF-8?q?10845=20=ED=81=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../B10845.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "\355\225\234\352\260\200\354\235\200/B10845.py" diff --git "a/\355\225\234\352\260\200\354\235\200/B10845.py" "b/\355\225\234\352\260\200\354\235\200/B10845.py" new file mode 100644 index 0000000..b9dfc7c --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/B10845.py" @@ -0,0 +1,18 @@ +import sys + +queue = [] +n = int(sys.stdin.readline()) +for _ in range(n): + command = list(sys.stdin.readline().split()) + if command[0] == "push": + queue.append(command[1]) + elif command[0] == "pop": + print(queue.pop(0) if queue else -1) + elif command[0] == "size": + print(len(queue)) + elif command[0] == "empty": + print(0 if queue else 1) + elif command[0] == "front": + print(queue[0] if queue else -1) + else: #back + print(queue[-1] if queue else -1) \ No newline at end of file From ae7b426da36248ff3ab841a6623e4fb4a6bf5a26 Mon Sep 17 00:00:00 2001 From: Han Ga Eun Date: Mon, 7 Oct 2024 15:10:51 +0900 Subject: [PATCH 5/7] 10866 --- .../10866.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\355\225\234\352\260\200\354\235\200/10866.py" diff --git "a/\355\225\234\352\260\200\354\235\200/10866.py" "b/\355\225\234\352\260\200\354\235\200/10866.py" new file mode 100644 index 0000000..10d9e95 --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/10866.py" @@ -0,0 +1,24 @@ +from collections import deque +import sys + +n = int(input()) +answer = deque() +for _ in range(n): + a = list(sys.stdin.readline().split()) + + if a[0] == 'push_front': + answer.appendleft(a[1]) + elif a[0] == 'push_back': + answer.append(a[1]) + elif a[0] == 'pop_front': + print(answer.popleft() if answer else -1) + elif a[0] == 'pop_back': + print(answer.pop() if answer else -1) + elif a[0] == 'size': + print(len(answer)) + elif a[0] == 'empty': + print(0 if answer else 1) + elif a[0] == 'front': + print(answer[0] if answer else -1) + else : # a == 'back' + print(answer[-1] if answer else -1) \ No newline at end of file From 49e88ee4b6c07aba5691782d00d9ce92c20cc2af Mon Sep 17 00:00:00 2001 From: Han Ga Eun Date: Mon, 7 Oct 2024 16:14:59 +0900 Subject: [PATCH 6/7] 4949 --- .../4949.py" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "\355\225\234\352\260\200\354\235\200/4949.py" diff --git "a/\355\225\234\352\260\200\354\235\200/4949.py" "b/\355\225\234\352\260\200\354\235\200/4949.py" new file mode 100644 index 0000000..d937eed --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/4949.py" @@ -0,0 +1,28 @@ +import sys + +while True: + state = True + stack = [] + commands = list(sys.stdin.readline().rstrip()) + if commands == ['.']: # command는 list이기 때문에 []리스트로 일치 판별 + break + for char in commands: + if char == '(': + stack.append('(') + elif char == '[': + stack.append('[') + elif char == ')': + if stack and stack.pop() == '(': + state = True + else: + state = False + break + elif char == ']': + if stack and stack.pop() == '[': + state = True + else : + state = False + break + if stack: + state = False #stack이 비었을 때만 yes + print('yes' if state else 'no') \ No newline at end of file From 900e134b13e3d6a7dcfa06632fdb2064eb0523d4 Mon Sep 17 00:00:00 2001 From: Han Ga Eun Date: Thu, 21 Nov 2024 11:47:15 +0900 Subject: [PATCH 7/7] =?UTF-8?q?7=ED=9A=8C=EC=B0=A8=2015649,=20N=EA=B3=BC?= =?UTF-8?q?=20M?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649.py" | 18 ++++++++++++++++++ .../15650.py" | 14 ++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 "\355\225\234\352\260\200\354\235\200/15649.py" create mode 100644 "\355\225\234\352\260\200\354\235\200/15650.py" diff --git "a/\355\225\234\352\260\200\354\235\200/15649.py" "b/\355\225\234\352\260\200\354\235\200/15649.py" new file mode 100644 index 0000000..9f8c30b --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/15649.py" @@ -0,0 +1,18 @@ +def back_tracking(arr, len, used_num): + if len == m: + print(*arr) + return + + for i in range(1, n+1): + if not used_num[i]: + arr.append(i) + used_num[i] = True + back_tracking(arr, len + 1, used_num) + arr.pop() + used_num[i] = False + +n, m = list(map(int, input().split())) + +nums = [i+1 for i in range(n + 1)] +used_num = [False] * (n+1) +back_tracking([], 0, used_num) diff --git "a/\355\225\234\352\260\200\354\235\200/15650.py" "b/\355\225\234\352\260\200\354\235\200/15650.py" new file mode 100644 index 0000000..727dfc8 --- /dev/null +++ "b/\355\225\234\352\260\200\354\235\200/15650.py" @@ -0,0 +1,14 @@ +def backtracking (arr, start): + if m == len(arr): + print(*arr) + return + + for i in range(start, n+1): + arr.append(i) + backtracking(arr, i+1) + arr.pop() + + +n, m = list(map(int, input().split())) +s = 1 +backtracking([], s) \ No newline at end of file