Skip to content

Commit

Permalink
2024-06-03
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu committed Jun 3, 2024
1 parent a10a552 commit 2f3e18e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions H0ngJu/DFS/์Šคํƒ€ํŠธ์™€ ๋งํฌ.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

---

0 comments on commit 2f3e18e

Please sign in to comment.