Here is the A of todays contest. Inbox for more. Poor people are discouraged to knock

Revision en2, by ArefiX, 2025-03-15 09:54:49

Text format: Binary Matrix

Problem Statement:

A matrix is called binary if all its elements are either 0 or 1.

Ecrade calls a binary matrix good if the following two properties hold:

  1. The bitwise XOR of all numbers in each row of the matrix is equal to 0.
  1. The bitwise XOR of all numbers in each column of the matrix is equal to 0.

Ecrade has a binary matrix of size n × m. He is interested in finding the minimum number of elements that need to be changed for the matrix to become good.

Input:

Each test contains multiple test cases.

The first line contains the number of test cases t (1 ≤ t ≤ 400).

The first line of each test case contains two integers n, m (1 ≤ n, m ≤ 100).

This is followed by n lines, each containing exactly m characters (0 or 1), describing the elements of Ecrade's matrix.

It is guaranteed that the sum of n * m across all test cases does not exceed 5 × 10⁴.

Output:

For each test case, output a single integer:

The minimum number of elements that need to be changed.

Tags question, business

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ArefiX 2025-03-15 09:54:49 37 Tiny change: '![ ](https://ibb.co.com/ymw6wbRN)\n\nText forma' -> 'Text forma'
en1 English ArefiX 2025-03-15 09:51:18 1175 Initial revision (published)