Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A matrix keypad consists of an r c grid of buttons. Additionally, there is one wire for each row and one wire for each column.

A matrix keypad consists of an rc grid of buttons.
Additionally, there is one wire for each row and one wire
for each column. These wires are exposed through pins
so the keypad can be connected to a larger circuit.
When a button at row i and column j is pressed, the wire
for row i and the wire for column j will carry an electrical
current. If just a single button is pressed, it can be
identified by sequentially checking if a current can be
detected at each row wire and at each column wire.
Unfortunately, when multiple buttons are pressed at the
same time, it may not be possible to uniquely identify which buttons are pressed.
The only information you can have is this: for each wire, whether there is at least
one button along that wire being pressed.
The software you are using to detect which buttons are pressed was poorly
implemented. After probing the keypad, it stores the information in an rc grid
of 01 values. The value stored in row i and column j of this grid is 1 if there is at
least one button in row i and at least one (possibly different) button in column j
that is pressed. Otherwise, the value that is stored at this position is 0.
Your job is to interpret as much information from such a grid as possible.
Determine which buttons are definitely pressed and which buttons are definitely
not pressed.
Input
The first line of input contains a single positive integer T200 indicating the
number of test cases. The first line of each test case contains two integers r and c
where 1r10 and 1c10. This indicates that the keypad is an rc grid
of buttons.
The remaining r lines of a test case describe the grid. The i th row contains a
string of consecutive 0 and 1 characters. These will not be separated by spaces.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions