From acc71ad8c2bc419f9761732df0f3a607bf200941 Mon Sep 17 00:00:00 2001 From: Heo Nayeong Date: Tue, 2 Jul 2024 03:01:58 +0900 Subject: [PATCH] 41-gjsk132 --- gjsk132/README.md | 3 +- ...0\354\233\220 \354\210\234\355\232\214.py" | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 "gjsk132/TSP/2098 \354\231\270\355\214\220\354\233\220 \354\210\234\355\232\214.py" diff --git a/gjsk132/README.md b/gjsk132/README.md index 759c020..b5ed9ee 100644 --- a/gjsk132/README.md +++ b/gjsk132/README.md @@ -38,4 +38,5 @@ | 36차시 | 2024.05.18 | Geometry | [다각형의 면적](https://www.acmicpc.net/problem/2166) | [⛧](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/174) | | 37차시 | 2024.05.22 | DP | [26093 고양이 목에 리본 달기](https://www.acmicpc.net/problem/26093) | [🐱](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/176) | | 38차시 | 2024.05.24 | BFS | [17836 공주님을 구해라!](https://www.acmicpc.net/problem/17836) | [👸](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/180) | -| 39차시 | 2024.05.29 | Dijkstra | [11781 퇴근 시간](https://www.acmicpc.net/problem/11781) | [🚌](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/183) | \ No newline at end of file +| 39차시 | 2024.05.29 | Dijkstra | [11781 퇴근 시간](https://www.acmicpc.net/problem/11781) | [🚌](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/183) | +| 41차시 | 2024.07.01 | TSP | [2098 외판원 순회](https://www.acmicpc.net/problem/2098) | [✈️](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/195) | \ No newline at end of file diff --git "a/gjsk132/TSP/2098 \354\231\270\355\214\220\354\233\220 \354\210\234\355\232\214.py" "b/gjsk132/TSP/2098 \354\231\270\355\214\220\354\233\220 \354\210\234\355\232\214.py" new file mode 100644 index 0000000..f07df5c --- /dev/null +++ "b/gjsk132/TSP/2098 \354\231\270\355\214\220\354\233\220 \354\210\234\355\232\214.py" @@ -0,0 +1,31 @@ +input = open(0).readline + +N = int(input()) + +cost = [list(map(int, input().split())) for _ in range(N)] + +INF = float('inf') +dp = [[0]*((1 << N) - 1) for _ in range(N)] + +def DFS(now, visited): + if visited == (1<