编程介的小学生 2020-01-29 13:11 采纳率: 20.5%
浏览 84

Choose The Soldiers 选择和匹配的问题

Problem Description
There are N matrixs of soilders.
Now here comes an urgent task and you want to choose M of them to complete the task.
But if more than 2 selected soldiers are in the same row or column of the same matrix they will chat to each other and the efficiency will be too low.
Of course you want to avoid low efficiency.
How many ways can you choose them?

Input
There are several test cases. The first line of the input is an integer T (0<T<=100) indicates the number of test cases.
The first line of each test case is a line of 2 positive integers N(0<N<=20) and M (0<M<=800).
Then N lines of 2 integers, m and n (0<m,n<=20) indicate the number of row and column of each matrix.

Output
The result may be very large so for each test case output the result module by 123456789 instead in a single line.

Sample Input
2
1 1
1 1
2 2
1 1
2 2

Sample Output
1
10

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 iqoo11 如何下载安装工程模式
    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?