Medium Accuracy: 40.39% Submissions: 6546 Points: 4
Given a graph, the task is to check if it contains a negative weight cycle or not.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains 2 lines the first line contains two space separated integers v and e denoting the no of vertices and no of edges respectively. Then in the next line are 3*e space separated values x,y,z denoting an edge from x to y with a weight of z.
For each test case in a new line print 0 if there is no negative weight cycle else print 1.
1 <= T <= 50
1 <= v <= 100
1 <= e <= 50