Square Network

TimeLimit:8000MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Alice and Bob are extremely happy recently. Because the school assigns a new machine room to their lab. They are in charge of setting up a group of servers. In the room, there are $N \times N$ blanks to put servers. Alice wants the arrangement of servers to be elegant, so she thinks that some blanks must be empty, while others must not be empty. According to the need of lab, Bob is planning to purchase $K$ types of severs. Moreover, he gives $T$ groups of blanks, where one blank might be contained in different groups. Each group has exactly $K$ blanks, and any two of servers in the blanks of one group must not be the same type. Now, some servers has been put in some blank, which can not be changed. With all these conditions, Alice and Bob want to know how many ways that they can arrange the machine room.
Input
The first line is the number of test cases.
For each test case, the first line consists of three integers $N$, $K$, and $T (N, K \leq 6, T\leq 12)$.
In the next $N$ lines, each line consists of $N$ integers $A_{i, j}$.If $A_{i, j} = -1$, the blank $(i, j)$ must be empty. If $A_{i, j} = 0$, a server is require to put on this blank. Otherwise, a server of type $A_{i, j}$ is on this blank.
In the next $T$ lines, each line consists of $K$ pair of integers. Each pair of integers donate the coordinate of blank in this group.
Output
For each test case, output an integer donating the ways that Alice and Bob can arrange the room. If the solution is larger than $20172017$, output `TOO MANY`.
SampleInput
2
3 3 4
0 0 1
0 -1 0
0 0 0
1 1 1 2 1 3
1 1 2 1 3 1
1 3 2 3 3 3
3 1 3 2 3 3
5 5 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
SampleOutput
6
TOO MANY
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: