Блог пользователя ArefiX

Автор ArefiX, история, 6 часов назад, По-английски

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.

  • Проголосовать: нравится
  • -23
  • Проголосовать: не нравится

»
6 часов назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Auto comment: topic has been updated by ArefiX (previous revision, new revision, compare).

»
6 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Don't downvote, i am helping humanity