Answered step by step
Verified Expert Solution
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 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 is pressed, the wire
for row i and the wire for column 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 grid
of values. The value stored in row i and column of this grid is if there is at
least one button in row i and at least one possibly different button in column
that is pressed. Otherwise, the value that is stored at this position is
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 indicating the
number of test cases. The first line of each test case contains two integers and
where and This indicates that the keypad is an grid
of buttons.
The remaining lines of a test case describe the grid. The th row contains a
string of consecutive and characters. These will not be separated by spaces.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started