WZB's Harem
1000ms 131072K
描述:
Do you remember N-queens? Today, WZB accompanied his n queens to the cinema……
As the saying goes: Three queens for a play, one harem admits of no two queens…
Cinema uses n rows of seats, each row has n columns.Queens are grumpy, they're not willing to sit in the same row or same column with other queen, if there are two queens in the same row or same column they conflict occurs, so they make WZB arrange seats for them. It stumped WZB to avoid the queen make antinomy. WZB wants to know how many different arrangements there are for the queen, he'd like to choose one for them.
Since WZB and his queens arrived late, some seats had already been reserved by others. Although WZB is a king, he can't infringe on the rights of citizens, so the reserved seats could not be reserved for queens.
Now WZB has ordered you to work out how many ways to arrange the queen. If WZB finds out your calculations are wrong....
输入:
There is an integer n(n<=20)n(n<=20) in the firstline. The cinema has n rows and n columns of seats.
In the next lines,there are n integers ineach line(0 or 1).If the point(i,j)(i,j) is 11, it means it has been booked.
输出:
One integer.You just need to print the answer Mod 10000000071000000007.
样例输入:
2 0 0 0 0
样例输出:
4
描述:
你还记得n皇后吗?今天,WZB陪他的n皇后去看电影。
俗话说:三个皇后一台戏,一个后宫不可以容下俩个皇后……
电影院使用的是n排座位,每一排都有n行。皇后们脾气暴躁,如果有两个皇后坐在相同的排或行她们会发生冲突,所以,她们让WZB帮她们安排座位。WZB想知道皇后们有多少种不同的安排,他可以为皇后们选择一种。
因为WZB和他的皇后们来晚了,有些座位已经被其他人预定了。虽然,WZB是国王,但是,他不想侵犯公民的权利,因此,已经被预定的座位不能提供给皇后们。
现在,WZB命令你想出到底有多少种方式可以安排皇后,如果WZB发现你的计算有误……
输入:
在第一行有一个整数n(n<=20),电影院有n行n列的座位。
在接下来的几行中,每行有n个整数(0或1)。如果点(i,j)是1,那就意味着该座位被预定。
样例输入:
2
0 0
0 0
样例输出:
4