you give undirected graph original graph n node label 0 n 1 you decide subdivide edge graph chain node number new node vary edgethe graph give 2D array edge edgesi ui vi cnti indicate edge node ui vi original graph cnti total number new node subdivide edge Note cnti 0 mean subdivide edgeTo subdivide edge ui vi replace cnti 1 new edge cnti new node the new node x1 x2 xcnti new edge ui x1 x1 x2 x2 x3 xcnti1 xcnti xcnti viIn new graph want know node reachable node 0 node reachable distance maxmove lessGiven original graph maxmove return number node reachable node 0 new graph example 1input edge 0110021122 maxmove 6 n 3output 13explanation the edge subdivision show image abovethe node reachable highlight yellowexample 2input edge 014126028131 maxmove 10 n 4output 23example 3input edge 124145131234345 maxmove 17 n 5output 1explanation Node 0 disconnected rest graph node 0 reachable Constraints0 edgeslength minn n 1 2 104edgesilength 30 ui vi nThere multiple edge graph0 cnti 1040 maxmove 1091 n 3000