eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Count the Number of Cycles

Count the Number of Cycles

In information theory, a low-density parity-check (LDPC) code is a linear error correcting code, a method of transmitting a message over a noisy transmission channel, and is constructed using a sparse bipartite graph. LDPC codes are capacity-approaching codes, which means that practical constructions exist that allow the noise threshold to be set very close (or even arbitrarily close on the BEC) to the theoretical maximum (the Shannon limit) for a symmetric memory-less channel. LDPC codes are defined by a sparse parity-check matrix. This parity-check matrix is often randomly generated and the elements in it are \textbf{0} or \textbf{1}. If we want use LDPC codes, we should make the parity-check matrix have no cycles. When four vertices of the rectangle in the matrix are 1, we say that the matrix has one cycle. Now we want to know how many cycles are in the matrix. For a given matrix, you are to count the number of cycles in the matrix. \InputFile There are several test cases, each test case starts with a line containing two positive integers \textbf{M} and \textbf{N}. \textbf{M} and \textbf{N} is the size of the matrix (\textbf{1} ≤ \textbf{M} ≤ \textbf{100}, \textbf{1} ≤ \textbf{N} ≤ \textbf{100}). Next follow a matrix which contains only number \textbf{0} and \textbf{1}. The input will finish with the end of file. \OutputFile For each the case, your program will output the number of cycles in the given matrix on separate line.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1 3
1 1 1
2 3
1 0 1
0 1 1
3 3
1 0 1
0 1 1
1 1 1
Вихідні дані #1
0
0
2
Джерело Hunan University 2011 the 7th Programming Contest