Editorial for WC '18 Contest 1 J4 - Germaphobia
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Let's define to be the minimum number of doors which Bob must pass through to get from classroom
to classroom
. The only options he should consider are to avoid the hallways and pass exclusively through classrooms (which requires
doors), or to go through the hallway (which always requires
doors). Therefore,
. The total answer is then the sum of
for each
from
to
, plus an extra
(for one door required to get from the hallway to the first class, and another door required to get from the final class to the hallway).
Comments