2652Simplified Travelling Salesman Problem

2652   Simplified Travelling Salesman Problem

题目描述

There are n cities in Kingdom xxx and m undirected roads connecting the cities. A travelling salesman starts from city s and wants to travel around the kingdom. Now you need to tell him the shortest path.

输入格式:

Multiple cases (<= 10).

For each test case, the first line consists of three integers n, m, s (1 <= n <= 16, m <= 10000, 1 <= s <= n). Then m lines follow, each line consists of three integers u, v, w (1 <= u, v <= n; 0 <= w <= 100), representing two endpoints and length of a road.

输出格式:

For each test data, output one line, representing answer. If the travelling salesman cannot travel around the kingdom, output -1.

输入样例 复制
5 5 1
1 2 2
1 3 3
1 4 4
1 5 5
4 5 6
输出样例 复制
20

说明

1
1
通过提交
时空限制1000ms/64mb
题目来源数据结构实验与竞赛训练
评测方式在线评测
题目类型
难        度