|Nộp bài||Các bài nộp||Làm tốt nhất||Về danh sách bài|
SCCHEM - Strongly Connected Chemicals
One type of chemical compounds is the ionic compound, because it is composed of positively charged ions (cations) and negatively charged ions (anions) in such a way that the compound as a whole is electrically neutral. Cations always attract anions and anions always attract cations.
Now you are given m cations and n anions, and their connectivity information about which cation attracts which anion. You task is to find a sub group from the cations and anions where there is at least one cation and at least one anion, such that all the cations in the group attract all the anions in the group. We call such a group as 'Strongly Connected Chemicals'. As there can be many such groups, we want to find a group which has the highest cardinality. Cardinality means the number of members (cation and anion) in the group.
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing two integers: m and n (1 ≤ m, n ≤ 50). Each of the next m lines contains n characters (without space), each either '0' or '1'. If the jth character in the ith line is 1, that means the ith cation attracts the jth anion, otherwise it doesn't.
For each case, print the case number and the maximum possible size of the strongly connected chemical group.
Output for Sample Input
Case 1: 4
Case 2: 2
|Được gửi lên bởi:||Race with time|
|Thời gian chạy:||1s|
|Giới hạn mã nguồn:||50000B|
|Cluster:||Cube (Intel G860)|
|Ngôn ngữ cho phép:||Tất cả ngoại trừ: ASM64 GOSU PERL6 PYPY RUST SED|