【题目描述】
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