给出4*4的网格平面,要求在这个16个格子里面放入楼层分别是1、2、3、4层高的楼栋;
要求每行以及每列的1~4层楼必须且只能出现一次;
给出条件是从每个方向上所能看到的不被遮挡的楼栋数目;
Example:
To understand how the puzzle works, this is an example of a row with 2 clues. Seen from the left side there are 4 buildings visible while seen from the right side only 1:
There is only one way in which the skyscrapers can be placed. From left-to-right all four buildings must be visible and no building may hide behind another building:
Example of a 4 by 4 puzzle with the solution:
代码(我这个是用穷举的方法来做的,先算出4!一共24种组合,然后依次遍历,其实比较笨,应该有更聪明的方法,以后有空了想想):
typedef struct _AssNode{
int Valuegroup[4];
int LeftViewCnt;
int RightViewCnt;
}As