I tried the problem (above), but the solution code provided by USACO doesn’t really make sense. Could someone perhaps explain that solution or provide another Flood Fill solution, perhaps involving a recursive floodfill approach.
I drew out the sample case, but I’m not really sure if my thought process concurs with what the problem states as “gates”.
Here is my fence drawing:
What doesn’t really make sense about the code? (btw i can give you my code if you think it’ll help)
Why dirx is -1 when dir = ‘N’
Here. It’s in Java though, so I can’t help you if you were looking for a C++ version.
For some reason they inverted all the directions. I guess(?) it makes working with array indices easier?
Does anyone here have a recursive solution?