10942: 带负权的单源最短路

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:2 Solved:0

Description

 输入一个有向网络图,边的权值可正可负,求顶点到其他各点的最短路。

Input

第一行输入n,表示n个结点(默认顶点为0号)

接下来输入n*n矩阵。表示各边的权值。

Output

输出一行,如果有负权回路输出“not possible”,否则输出顶点0到其他点的最短路,输出答案之间仅有一个空格,结尾没有空格。

Sample Input Copy

4
0 0 -3 0
2 0 0 0
0 -1 0 -4
0 0 0 0

Sample Output Copy

not possible