-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from HYU-PS-STUDY/leGit-y
[week-12] 1459, 1759
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |