luogu#P5074. Eat the Trees
Eat the Trees
Background
HDU1693: Eat the Trees
Problem Description
Given an grid, some cells cannot be filled with lines, and all other cells must be filled. Multiple closed loops can be formed. Ask how many different ways there are to fill the grid?
Input Format
Multiple test cases per input file. The first line contains a positive integer , meaning there are test cases.
For each test case:
Line : two integers .
Lines to : each line contains digits ( or ). means this cell must be filled with lines, and means this cell is not filled with lines.
Output Format
For each test case, output one integer, representing the number of valid ways. It is guaranteed that the answer is less than .
2
6 3
1 1 1
1 0 1
1 1 1
1 1 1
1 0 1
1 1 1
2 4
1 1 1 1
1 1 1 1
3
2
Hint
Translated by ChatGPT 5