[kuangbin]专题三 Dancing Links Exact cover HUST - 1017【精确覆盖】

【题目描述】
There is an N*M matrix with only 0s and 1s, (1 <= N,M <= 1000). An exact cover is a selection of rows such that every column has a 1 in exactly one of the selected rows.
Try to find out the selected rows.
有一个N * M的矩阵只有0和1组成(1 <= N,M <= 1000)。精确覆盖是选择几行使得每一列在所选行中的一列中都有一个1,尝试找出选定的行。

【输入】
There are multiply test cases.
First line: two integers N, M;
The following N lines: Every line first comes an integer C(1 <= C <= 100), represents the number of 1s in this row, then comes C integers: the index of the columns whose value is 1 in this row.
有多个测试样例。
第一行:两个整数N和M。
后面N行:每行第一个整数C(1 <= C <= 100),表示在这一行1的数量,后面C个整数表示1所在列的列标。

【输出】
First output the number of rows in the selection, then output the index of the selected rows.
If there are multiply selections, you should just output any of them.
If there are no selection, just output “NO”.
先输出所选的行数,然后输出所选行的行标。
如果有多种选择,你可以任意输出一种。
如果不能选择,就输出“NO”。

【样例输入】
6 7
3 1 4 7
2 1 4
3 4 5 7
3 3 5 6
4 2 3 6 7
2 2 7

【样例输出】
3 2 4 6

题目链接:https://cn.vjudge.net/problem/HUST-1017
写博客的时候hust还是交不了的,什么时候能交了请戳戳我QAQ

DLX模板题
代码就不挂了
kuangbin模板,出门右转→ https://www.cnblogs.com/kuangbin/p/3752854.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值