Iwillgotit's blog

By Iwillgotit, history, 6 months ago, In English

+Given a directed and weighted graph and k vertices.Find the shortest path that go through all k vertices?
time limit : 3 seconds

+input:
first line contain n,m,k : n is number of vertices ,m is number of edges,k is number of givens vertices
second line contain k vertices
m last lines contain x,y,z : that mean have a edge conect between x and y and z is the weight of this edge

example
+constrains: 1<=k<=n<=20

Input:
6 10 3
4 5 6
1 2 1
2 3 3
3 4 3
4 5 1
5 6 3
6 1 3
1 5 1
6 3 3
2 4 1
5 3 3

Output: 4

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it