#P4929. 【模板】舞蹈链(DLX)

    ID: 3908 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>搜索Special Judge剪枝Dancing Links状态压缩,状压

【模板】舞蹈链(DLX)

Description

Given a matrix with NN rows and MM columns, each element in the matrix is either 11 or 00.

You need to select some rows from the matrix so that for every column jj of the matrix, among the selected rows, there is one and only one row whose jj-th element is 11.

Input Format

The first line contains two integers N,MN, M.

The next NN lines each contain MM digits 00 or 11, representing the matrix.

Output Format

Output one line containing several integers representing the answer. Separate numbers with spaces. Any feasible solution is acceptable, and the order can be arbitrary.

If there is no solution, output No Solution!.

3 3
0 0 1
1 0 0
0 1 0

2 1 3

3 3
1 0 1
1 1 0
0 1 1

No Solution!

Hint

For 100%100\% of the testdata, N,M500N, M \leq 500, and the number of 11 in the matrix is guaranteed to be at most 50005000.

Translated by ChatGPT 5