How to fill the chessboard with domino? [closed]
How we can to fill the chessboard with domino and we have a some blocks. and chessboard is n x m
. and the places filled with ordered numbers.
Test :
Answer like this :
input give n , m and k. k
is number of blocks.
and next k lines give blocks such as 6 7
or 4 9
.
sorry for my English.
Here's an idea. In your example board, it is immediately obvious that squares 7
9
and 14
must contain domino 'ends', that is to say it must be the case that there are dominos covering 2-7
, 8-9
, and 14-15
.
(In case it's not 'immediately obvious', the rule I used is that a square with 'walls' on three sides dictates the orientation of the domino covering that square)
If we place those three dominos, it may then be the case that there are more squares to which the same rule now applies (eg 20
).
By iterating this process, we can certainly make progress towards our goal, or alternatively get to a place where we know it can't be achieved.
See how far that gets you.
edit also, note that in your example, the lower-left corner 2x2 (squares 11 12 16 17) is not uniquely determined - a 90 degree rotation of the depicted arrangement would also work - so you will have to consider such situations. If you are looking for any solution, you must come up with a way of arbitrarily picking one of many possibilities; if you are trying to enumerate all possibilities, you will have to come up with a way of finding them all!
精彩评论