https://cn.vjudge.net/contest/256971#problem/J
Treasure Map
You have found a treasure map! The map leads you to several gold mines. The mines
each produce gold each day, but the amount of gold that they produce diminishes each
day. There are paths between the mines. It may take several days to go from one mine
to a
nother. You can collect all of the day’s gold from a mine when you are there, but you
have to move on, you cannot stay for multiple days at the same mine.
However, you can
return to a mine after leaving it.
Input
Each input will consist of a single test ca
se. Note that your program may be run multiple
times on different inputs. Each test case will
begin with a line containing
two integersn(2 ≤n≤ 1,000)andm(1≤m≤ 1,000), wherenis thenumber of mines, andmis thenumber of paths.The n