// yukicoder: No.845 最長の切符 // 2019.6.29 bal4u #include #include #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } int N, M; int map[16][16]; int dp[65536][16]; int main() { int i, a, b, c, lim, ans; N = in(), M = in(); while (M--) { a = in()-1, b = in()-1, c = in(); if (map[a][b] < c) map[a][b] = map[b][a] = c; } lim = 1 << N, ans = 0; memset(dp, -1, sizeof(dp)); for (a = 0; a < N; a++) dp[1< 0) { if (((i >> a) & 1) && !((i >> b) & 1) && dp[i][a] >= 0) { c = dp[i][a] + map[a][b]; if (c > dp[i|(1< ans) ans = c; } } } } printf("%d\n", ans); return 0; }