EZDIJKST  Easy Dijkstra Problem
Determine the shortest path between the specified vertices in the graph given in the input data.
Hint: You can use Dijkstra's algorithm.
Hint 2: if you're a lazy C++ programmer, you can use set and cin/cout (with sync_with_stdio(0))  it should suffice.
Input
first line  one integer  number of test cases
For each test case the numbers V, K (number of vertices, number of edges) are given,
Then K lines follow, each containing the following numbers separated by a single space:
a_{i}, b_{i}, c_{i}
It means that the graph being described contains an edge from a_{i} to b_{i},
with a weight of c_{i}.
Below the graph description a line containing a pair of integers A, B is present.
The goal is to find the shortest path from vertex A to vertex B.
All numbers in the input data are integers in the range 0..10000.
Output
For each test case your program should output (in a separate line) a single number C  the length of the shortest path from vertex A to vertex B. In case there is no such path, your program should output a single word "NO" (without quotes)
Example
Input: 3 3 2 1 2 5 2 3 7 1 3 3 3 1 2 4 1 3 7 2 3 1 1 3 3 1 1 2 4 1 3 Output: 12 5 NO
hide comments
surya97:
20160510 07:16:21
Solved in 0.18s in Java. Costed 1 WA for using undirected graph. 

bruzelee:
20160503 23:43:40
Given graph is directed !!! 

ankushbbbr:
20160405 19:19:28
getting a wrong answer with java 

try2catch:
20160212 08:47:11
1ST GO AC ! problem is a bitch! _ 

maxeinstle:
20160202 06:59:17
Directed Graph!! Be Careful. 

epsilon:
20160124 14:16:59
stl rocks :)


Nguyen Cuong:
20160103 08:58:31
my first dijkstra problem ^_^ 

sumit suthar:
20151114 09:56:58
Take it eazy.. ;) 

Karen:
20151105 19:34:45
Graph is directed!


vinod_10147:
20151024 06:31:49
got AC in 0.00s 
Added by:  Robert Rychcicki 
Date:  20090110 
Time limit:  0.150s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JS NODEJS objc PERL 6 VB.net 