diff --git "a/H0ngJu/DFS/\354\212\244\355\203\200\355\212\270\354\231\200 \353\247\201\355\201\254.py" "b/H0ngJu/DFS/\354\212\244\355\203\200\355\212\270\354\231\200 \353\247\201\355\201\254.py" new file mode 100644 index 00000000..be837105 --- /dev/null +++ "b/H0ngJu/DFS/\354\212\244\355\203\200\355\212\270\354\231\200 \353\247\201\355\201\254.py" @@ -0,0 +1,35 @@ +import sys + +def input() : return sys.stdin.readline().rstrip() + +N = int(input()) +arr = [list(map(int, input().split())) for _ in range(N)] +visited = [0] * N +answer = 999999999 + +def solution(len, idx): + global answer + + if len == N//2: + link = 0 + start = 0 + + for i in range (N): + for j in range (N): + if visited[i] and visited[j]: # 방문한 반만 팀 + start += arr[i][j] + elif not visited[i] and not visited[j]: # 나머지 반 팀 + link += arr[i][j] + + answer = min(answer, abs(start-link)) + return + + else: # 인원 나누기 + for i in range(idx, N): + if not visited[i]: + visited[i] = 1 + solution(len+1, i+1) + visited[i] = 0 + +solution(0,0) +print(answer) \ No newline at end of file diff --git a/H0ngJu/README.md b/H0ngJu/README.md index df71f8e0..98210e7c 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -21,5 +21,6 @@ | 17차시 | 2024.05.22 | BFS | [적록색약](https://www.acmicpc.net/problem/10026) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/195 | | 18차시 | 2024.05.26 | DFS | [계란으로 계란치기](https://www.acmicpc.net/problem/16987) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/199 | | 19차시 | 2024.05.31 | DP | [합분해](https://www.acmicpc.net/problem/2225) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/202 | +| 20차시 | 2024.06.03 | 백트래킹 | [스타트와 링크](https://www.acmicpc.net/problem/14889) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/206 | ---