← Back to topics
Topic

Chess

m
msantl
I have trouble with this task. I find all the possible kings positions, and then try them all. I know why i get tle, but i can't see what to do.

http://www.z-trening.com/submit.php?subm_stat=1&submit=7100065035

Any help would be appreciated.
m
msantl
I saw this on chat ,

ortschun @ 15:41
anh hints for Chess?


As you can see , the restriction for m is quite small ( <= 10 ). You could generate all possible bitmasks that could represent a valid state in 1 row. Then you just count the number of ways to get from 1. row to n-th row using only valid states as valid neighbors. (Valid neighbor , you can go from 0000->0010, but you can't go from 0010->0100, because the king must have all neighbor positions free.)


o
ortschun
I've just seen this =) nice idea! thanks!