Bessie and Farmer John enjoy goat kart racing. The idea is very similar to Go-Kart racing that others enjoy, except the karts are pulled by goats and the track is made from nearby farmland. The farmland consists ofNmeadows andMroads, each connecting a pair of meadows. Bessie wants to make a course from nearby farms. A farm is a subset of two or more meadows within which every meadow can reach every other meadow along a unique sequence of roads. The nearby farmland may contain multiple farms. Suppose there areKfarms. Bessie would like to make a goat kart loop by connecting allKfarms by addingKroads of lengthX. Each farm should be visited exactly once and at least one road must be traversed inside each farm. To make the course interesting for racers, the total length of the track should be at leastY. Bessie wants to know the sum, over all such interesting tracks, of the total track lengths. A track is different from another if there are two meadows which are adjacent in one track but not the other. Please note that only the roads chosen matter, and not the direction the goat karts will travel along those roads.
Bessie and Farmer John enjoy goat kart racing. The idea is very similar to Go-Kart racing that others enjoy, except the karts are pulled by goats and the track is made from nearby farmland. The farmland consists of N meadows and M roads, each connecting a pair of meadows. Bessie wants to make a course from nearby farms. A farm is a subset of two or more meadows within which every meadow can reach every other meadow along a unique sequence of roads. The nearby farmland may contain multiple farms. Suppose there are K farms. Bessie would like to make a goat kart loop by connecting all K farms by adding K roads of length X. Each farm should be visited exactly once and at least one road must be traversed inside each farm. To make the course interesting for racers, the total length of the track should be at least Y. Bessie wants to know the sum, over all such interesting tracks, of the total track lengths. A track is different from another if there are two meadows which are adjacent (after adding the roads between farms) in one track but not the other. Please note that only the roads chosen matter, and not the direction the goat karts will travel along those roads.
标签: HBC24266胖胖的小宝 图论 最短路 广度优先搜索(BFS) 搜索[USACO 2019 Feb P]Moorio Kart题解