Loop nest

TimeLimit:2000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
There are $m$ sets $P_i,Q_i$,$\forall i(1\leq i\leq m),Pi,Qi\subseteq \{1…i-1\}$. There are nested loops with $m$ layers, and for the $j$th layer, the loop variable is $i_j$, the lower bound equals $\max\{i_k(k\in P_j)\}$(especially, when $P_j$ is empty set, it means the lower bound equals $1$), the upper bound equals $\min\{i_k(k\in Q_j)\}$(especially, when $Q_j$ is empty set, it means the upper bound equals $n$). HazelFan want to know how many times the loop body will be executed, module $p$.
Input
The first line contains a positive integer $T(1\leq T\leq5)$, denoting the number of test cases.
For each test case:
The first line contains three positive integers $m,n,p(1\leq m\leq15,1\leq n\leq10^9,2\leq p\leq10^9+7)$.
The next $m$ lines, the $i$th line contains several nonnegative integers describing the sets $P_i,Q_i$. The first integer is $A_i$, denoting the size of $P_i$, then next $A_i$ integers denotes the elements of $P_i$. The next integer is $B_i$, denoting the size of $Q_i$, then next $B_i$ integers denotes the elements of $Q_i$.
Output
For each test case:
A single line contains a nonnegative integer, denoting the answer.
SampleInput
2
2 10 233
0 0
1 1 0
6 10 987654321
0 0
1 1 0
0 0
1 3 0
0 1 4
1 2 2 1 2
SampleOutput
55
3850
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

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