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
Rana Saha:
20131112 20:15:46
weak test cases! 

Geanyous:
20131027 17:48:13
get AC for first submission with SPFA lol 

JosuĂ©:
20130208 03:53:50
It's a directed graph, that's why i was getting WA 

Kumar Mrinal:
20121225 18:38:31
gets AC with a noob implementation of Dijkstra, no need of heap nthing :)


Anick Saha:
20121128 20:02:32
guys, be careful wd one thing...it's a directed graph.. // ;) 

Rafael:
20121103 23:33:42
getting SIGKILL also for no reason


Prashant Gupta:
20120923 07:56:34
i m getting SIGKILL plzz chk


Prashant Gupta:
20120923 07:52:08
i m getting SIGKILL plzz chk


Panagiotis Kostopanagiotis:
20120716 20:35:17
Is it possible that one node is connected to itself, it's the only thing i can come up with so my program doesn't output the correct answer all the time :/ 

Piyush Raman Srivastava:
20120712 13:24:31
plz.. tell me why i am getting WA!

Added by:  Robert Rychcicki 
Date:  20090110 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS OBJC PERL6 VB.NET 