From 5cb6316e1ce6d0cdd9af5555b90b3bd62afd41cb Mon Sep 17 00:00:00 2001 From: sh0723 Date: Mon, 13 Jul 2026 17:02:20 +0900 Subject: [PATCH] =?UTF-8?q?2098=20:=20=EC=99=B8=ED=8C=90=EC=9B=90=20?= =?UTF-8?q?=EC=88=9C=ED=9A=8C=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week7/BOJ2098/BOJ2098_V1.cpp | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/week7/BOJ2098/BOJ2098_V1.cpp diff --git a/src/week7/BOJ2098/BOJ2098_V1.cpp b/src/week7/BOJ2098/BOJ2098_V1.cpp new file mode 100644 index 0000000..d72daf8 --- /dev/null +++ b/src/week7/BOJ2098/BOJ2098_V1.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; +int dist[16][16]; +int N; +int dp[16][1 << 16]; +int tsp(int here, int visited) { + if (visited == (1 << N)-1) + return dist[here][0] ? dist[here][0] : INT_MAX; + + int &ret = dp[here][visited]; + if (ret != -1) return ret; + ret = INT_MAX; + for (int i=0; i> N; + for (int i=0; i> dist[i][j]; + } + } + + memset(dp, -1, sizeof(dp)); + cout << tsp(0,1) << '\n'; + + + + return 0; +} \ No newline at end of file