ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1213. Cockroaches!

Why the answer is Number_of_Compartments-1
Posted by Pegasus 5 Dec 2012 07:37
who can prove it
Re: Why the answer is Number_of_Compartments-1
Posted by viknick 21 Feb 2015 22:05
if the amount of baffles that should be opened is equal to N - 2, it will be not enough, because graph will be not connected, and that's why not all cockcroaches will reach the floodgate. But you can build the spanning tree of this graph. It has exactly N - 1 edges, and graph will be connected and now all cockroaches will reach the floodgate.