Home => ProblemSet => 模4最优路径问题
Problem2238--模4最优路径问题

2238: 模4最优路径问题

Time Limit: 1 Sec  Memory Limit: 128 MB  Submit: 0  Solved: 0
[ Submit ] [ Status ] [ Creator: ][ 参考程序 ]

Description




从1到4找出一条路径,要求路径的总长度mod4的余数最小。

Input

第一行两个数n m,分别表示n个顶点,m条边
接下来m行,表示每两个相邻顶点之间有3条边的权值长度

Output

一个整数,表示最短路径mod4的最小值

Sample Input Copy

4 3
3
1
1
1
2
2
1
2
3

Sample Output Copy

0

HINT

1 <= n <= 1000


Source/Category