spoj IITWPC4I, Petya and Repairment of Roads

nice and easy graph problem,
the simple trick is to join all the milkman to a special extra node with 0 weighted edges. now we just have to find the minimum spanning tree for this new Graph.

https://gist.github.com/558f4655a5db88fc316b

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s