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 1367. Top Secret

Precautions
Posted by Denis Koshman 24 Aug 2008 05:35
Some implementation bugs I had

1. Some secret may become reachable several times from different sides when filling some area. Make sure that list of reachable secrtets does not overflow due to that.

2. If you test touching the secret along with testing walls, make sure you don't write something like that

if(!has_wall(...) || !has_wall(...))

where has_wall() returns true/false along with adding newly discovered secret to the list. The danger here is that if 1st operand of || is 'true', the 2nd one is not even evaluated according to C++ standard. So it might happen that some secret is not added to the list because 'has_wall' is not called due to free passage on the neighboring wall. But it's safe to replace boolean || with binary |. The latter is always evaluated for both operands even if the 1st one returns -1 (all ones).