B. Pipeline
time limit per test
2 seconds
memory limit per test
256 megabytes
@H_
301_29@
Vova,the Ultimate Thule new shaman,wants to build a pipeline. As there are exactlynhouses in Ultimate Thule,Vova wants the city to have exactlynpipes,each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has only one pipe with flowing water. Besides,Vova has several splitters.
A splitter is a construction that consists of one input (it can be connected to a water pipe) andxoutput pipes. When a splitter is connected to a water pipe,water flows from each output pipe. You can assume that the output pipes are ordinary pipes. For example,you can connect water supply to such pipe if there's water flowing out from it. At most one splitter can be connected to any water pipe.
The figure shows a4-output splitter
Vova has one splitter of each kind: with2,3,sans-serif">4,...,sans-serif">koutputs. Help Vova use the minimum number of splitters to build the required pipeline or otherwise state that it's impossible.
Vova needs the pipeline to have exactlynpipes with flowing out water. Note that some of those pipes can be the output pipes of the splitters.