diff --git a/hadongun/README.md b/hadongun/README.md index 0b54ed4..81fcc31 100644 --- a/hadongun/README.md +++ b/hadongun/README.md @@ -4,4 +4,8 @@ |:----:|:---------:|:----:|:-----:|:----:| | 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35| | 2차시 | 2025-03-21 | 그리디 알고리즘 | [로프] (https://www.acmicpc.net/problem/2217) - | 3차시 | 2025-03-21 | 수학 | [보물] (https://www.acmicpc.net/problem/1026) \ No newline at end of file + | 3차시 | 2025-03-21 | 수학 | [보물] (https://www.acmicpc.net/problem/1026) + | 4차시 | 2025-03-27 | 큐 | [카드2] (https://www.acmicpc.net/problem/2164) + | 5차시 | 2025-04-02 | 스택 | [스택2] (https://www.acmicpc.net/problem/28278) + | 6차시 | 2025-04-04 | 정렬 | [단어정렬](https://www.acmicpc.net/problem/1181) + | 7차시 | 2025-04-07 | 스택 | [균형잡힌 세상](https://www.acmicpc.net/problem/4949) \ No newline at end of file diff --git "a/hadongun/\354\212\244\355\203\235/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" "b/hadongun/\354\212\244\355\203\235/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" new file mode 100644 index 0000000..399a313 --- /dev/null +++ "b/hadongun/\354\212\244\355\203\235/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" @@ -0,0 +1,64 @@ +import sys +while True: + charrr = sys.stdin.readline().rstrip() + if charrr == ".": + break + are_you_balanced = True + stack = [] + for ch in charrr: + if ch == "(" or ch == "[": + stack.append(ch) + elif ch == ")": + if stack and stack[-1] == "(": + stack.pop() + else: + are_you_balanced = False + break + elif ch == "]": + if stack and stack[-1] == "[": + stack.pop() + else: + are_you_balanced = False + break + if are_you_balanced and not stack: + print("yes") + else: + print("no") + +'''import sys +stack = [] +roundbalance = 0 +anglebalance = 0 +while True: + charrr = sys.stdin.readline().strip() + for ch in charrr: + stack.append(ch) + if charrr == "": + break + while stack: + if stack[-1] == "(": + roundbalance += 1 + stack.pop() + elif stack[-1] == ")": + roundbalance -= 1 + stack.pop() + elif stack[-1] == "[": + anglebalance += 1 + stack.pop() + elif stack[-1] == "]": + anglebalance -= 1 + stack.pop() + else: + stack.pop() + if len(stack) == 0: + break + if roundbalance == 0 and anglebalance == 0: + print("yes") + else: + print("no")''' + + + + + + diff --git "a/hadongun/\354\240\225\353\240\254/\353\213\250\354\226\264\354\240\225\353\240\254.py" "b/hadongun/\354\240\225\353\240\254/\353\213\250\354\226\264\354\240\225\353\240\254.py" new file mode 100644 index 0000000..545bc63 --- /dev/null +++ "b/hadongun/\354\240\225\353\240\254/\353\213\250\354\226\264\354\240\225\353\240\254.py" @@ -0,0 +1,41 @@ +import sys + +def sort_word(): + n = int(input()) + unsorted_word = [sys.stdin.readline().strip() for _ in range(n)] + sorted_wording = set(unsorted_word) + sorted_word = sorted(sorted_wording, key = lambda x : (len(x), x)) + for word in sorted_word: + print(word) +sort_word() + + +""" +시간 초과가 발생한 코드. 맞는 지는 모르겠습니다. +def sort_word(): + n = int(input()) + unsorted_word = sys.stdin.read().splitlines() + for i in range(1, n): + key = len(unsorted_word[i]) + j = i -1 + + while j >=0 and key < len(unsorted_word[j]): + if key == len(unsorted_word[j]): + if unsorted_word[i] == unsorted_word[j]: + del unsorted_word[i] + if unsorted_word[j] > unsorted_word[i]: + temp = unsorted_word[j] + unsorted_word[j] = unsorted_word[i] + unsorted_word[j + 1] = unsorted_word[j] + unsorted_word[j] = unsorted_word[j] + j -= 1 + + + + + print(unsorted_word) +sort_word()""" + + + +