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 1121. Branches

The problem description is very unclear: here is a clarification
Posted by Otrebus 5 Jun 2015 16:23
Each crossroads in the input is the binary OR of its branches, so a 5 (binary 101) at some crossroads in the input means there are branches 4 (100) and 1 (001) there.

As for the output, for each crossroads where there are no branches (each 0, let's call this crossroads P), repeat this:
Find the Manhattan (vertical+horizontal) distance to the closest branch from C. In the description, this closest distance is 2. Next, find all branches that lie on this exact distance from C. In the description, these are branches with number 16, 8, and 4. The output at location P should reflect all types of branches at distance 2 by ORing these numbers together, and in the description we get 28 (binary 10000 | 1000 | 100).