๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • What would life be If we had no courage to attemp anything?
Problem Solving/SWEA

swea1865. ๋™์ฒ ์ด์˜ ์ผ ๋ถ„๋ฐฐ

by DevIseo 2022. 6. 2.

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5LuHfqDz8DFAXc 

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

def DFS(per,level):
    global Max,N
    if Max>= per: #์‹œ๊ฐ„์ดˆ๊ณผ ๋‚˜์„œ ๋ฐฑํŠธ๋ž˜ํ‚น
        return

    if level == N:
        if Max<per:
            Max=per
        return

    for i in range(N):
        if not visit[i]: #์•„์ง ๋ฐฉ๋ฌธ ์•ˆํ–ˆ์„ ๋•Œ
            visit[i] = 1
            DFS(per*(arr[level][i]/100),level+1)
            visit[i] = 0

T = int(input())
for tc in range(1,T+1):
    N = int(input())
    arr = [list(map(int,input().split())) for _ in range(N)]
    visit = [0]*N
    Max = 0
    DFS(1,0) # percentage,level
    print(f'#{tc} {Max*100:.6f}') #์†Œ์ˆซ์  6์ž๋ฆฌ๊นŒ์ง€..

 

๋Œ“๊ธ€