#P4039. [AHOI2014/JSOI2014] 拼图
[AHOI2014/JSOI2014] 拼图
Description
JYY has recently become obsessed with jigsaw puzzles. As a computer scientist, JYY has a set of black-and-white puzzle pieces. He hopes that by concatenating them properly, the final assembled pattern will contain an all-white subrectangle with the largest possible area.
JYY has puzzle pieces, numbered from to . The piece numbered is a grid rectangle with rows and columns, where each cell is either black or white. At the beginning, JYY places these pieces on the table side by side from left to right in numerical order, forming a large by rectangle (where ).
Later, JYY discovers that by changing the concatenation order of these pieces, the area of the maximum all-white subrectangle in the resulting by rectangle can be increased.
Now JYY wants to know how to arrange the pieces to obtain the largest possible all-white subrectangle. Please help him compute the optimal concatenation order.
Input Format
The first line contains an integer , the number of test cases. The descriptions of the test cases follow.
For each test case, the first line contains two integers and .
Then follow groups of input, where the -th group corresponds to puzzle piece .
In the -th group, the first line contains an integer ; then lines describe a -row by -column matrix; if the cell at row , column is , then the color at that position of the piece is white, otherwise it is black.
Output Format
For each test case, output one line containing a single integer ans, which denotes the area of the largest possible all-white subrectangle.
1
3 4
4
1001
0000
0010
1001
3
000
010
000
011
2
00
10
01
00
6
Hint
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号