Hyunwoo's DATA
boj-2529 부등호 본문
https://www.acmicpc.net/problem/2529
얼마전에 풀었던 문제랑 거의 유사해서 쉽게 풀수 있었다.
N = int(input())
op=input().split()
arr=[False]*10
mx, mn="", ""
def booleen(x,y,k):
if k=='<':
return x < y
if k=='>':
return x > y
return True
def solve(idx,s):
global mx,mn
if idx==(N+1):
if not len(mn):
mn = s
else:
mx = s
return
for i in range(10):
if not arr[i]:
if idx==0 or booleen(s[-1],str(i),op[idx-1]):
arr[i]=True
solve(idx+1, s+str(i))
arr[i]=False
solve(0,"")
print(mx)
print(mn)