From 249bb47d816660a332c68d6430807ff60f2cf6c4 Mon Sep 17 00:00:00 2001 From: yelin Date: Sun, 14 Apr 2024 21:59:32 +0900 Subject: [PATCH] [week-12-random] 1459, 1759 --- week12/leGit-y/.gitkeep | 0 week12/leGit-y/1459.py | 39 +++++++++++++++++++++++++++++++ week12/leGit-y/1759.py | 52 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) delete mode 100644 week12/leGit-y/.gitkeep create mode 100644 week12/leGit-y/1459.py create mode 100644 week12/leGit-y/1759.py diff --git a/week12/leGit-y/.gitkeep b/week12/leGit-y/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/week12/leGit-y/1459.py b/week12/leGit-y/1459.py new file mode 100644 index 0000000..78271d5 --- /dev/null +++ b/week12/leGit-y/1459.py @@ -0,0 +1,39 @@ +import sys +input = sys.stdin.readline + +X, Y, W, S = map(int, input().split()) + +result = -1 +move = X+Y + + +# 2*블록 > 대각선 +# 최대한 대각선으로 이동 +if 2 * W > S: + # 지그재그(대각선)로 돌아가더라도 돌아가는게 더 빠른 경우 + if W > S: + # 대각선으로만 이동이 가능한 좌표일 경우 + if move % 2 == 0: + result = S * max(X,Y) + else: + result = S * (max(X,Y) - 1) + W + # 돌아가지지 않고 직진하는게 더 빠른 경우 + else: + result = min(X, Y) * S + abs(X - Y) * W + +# 2*블록 <= 대각선 +# 최대한 가로,세로로 이동 +else: + result = W * move + + +print(result) + + + + + + + + + diff --git a/week12/leGit-y/1759.py b/week12/leGit-y/1759.py new file mode 100644 index 0000000..5e28ca1 --- /dev/null +++ b/week12/leGit-y/1759.py @@ -0,0 +1,52 @@ +""" +조건: 최소 1개의 모음 + 최소 2개의 자음 +증가하는 순서로 배열 +""" +import sys +input = sys.stdin.readline + +L, C = map(int, input().split()) +alpha = list(input().split()) + + +alpha.sort() +result = [] + +def check_vowel(alpha): + if alpha == 'a' or alpha == 'e' or alpha == 'i' or alpha == 'o'\ + or alpha == 'u': + return 0 + return 1 + +def _print(): + for a in result: + print(a, end='') + print() + +""" +check_1 : 모음 개수 체크 +check_2 : 자음 개수 체크 +""" +def dfs(depth, idx, check_1, check_2): + if depth == L: + if check_1 >= 1 and check_2 >= 2: + _print() + return + + for i in range(idx, C): + check = check_vowel(alpha[i]) + if check: + check_2 += 1 + else: + check_1 += 1 + + result.append(alpha[i]) + dfs(depth+1, i+1, check_1, check_2) + result.pop() + if check: + check_2 -= 1 + else: + check_1 -= 1 + + +dfs(0,0,0,0)