def get_num(x, y, oper):
if oper == '<':
if x > y :
return False
else:
if x < y:
return False
return True
def dfs(idx, num):
if idx == k+1:
ans.append(num)
return
for i in range(10):
if not check[i]:
if idx == 0 or get_num(num[idx-1], str(i), oper[idx-1]):
check[i] = True
dfs(idx + 1, num + str(i))
check[i] = False
k = int(input())
oper = list(input().split())
check = [False] * 10
ans = []
dfs(0, '')
ans.sort()
print(ans[-1])
print(ans[0])
'Algorithm > Python' 카테고리의 다른 글
[Algorithm|Python] 백준 15686번 / 99클럽 15일차 TIL (0) | 2025.02.08 |
---|---|
[Algorithm|Python] 백준 2615번 / 99클럽 14일차 TIL (0) | 2025.02.07 |
[Algorithm|Python] 백준 1051번 / 99클럽 12일차 TIL (0) | 2025.02.05 |
[Algorithm|Python] 백준 1018번 / 99클럽 코테 스터디 11일차 TIL (0) | 2025.02.04 |
[Algorithm|Python] 백준 2776번 / 99클럽 코테 스터디 10일차 TIL (0) | 2025.01.25 |