[Solution] N Buttons 1 Bulb CodeChef Solution
Problem
Kulyash stays in room that has a single bulb and buttons. The bulb is initially on.
The initial states of the buttons are stored in a binary string of length — if is , the -th button is off, and if is , the -th button is on. If Kulyash toggles any single button then the state of the bulb reverses i.e. the bulb lights up if it was off and vice versa.
Kulyash has toggled some buttons and the final states of the buttons are stored in another binary string of length . He asks you to determine the final state of the bulb.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of three lines of input.
- The first line of each test case contains an integer — the number of buttons.
- The second line of each test case contains a binary string — the initial states of the buttons.
- The third line of each test case contains a binary string — the final states of the buttons.
Is it hot or cold CodeChef Solution
Maximise the Tastiness CodeChef Solution
N Buttons 1 Bulb CodeChef Solution
Valid Minimum CodeChef Solution
High Frequency CodeChef Solution
Output Format
For each test case, output on a new line the final state of the bulb ( for off and for on).
Explanation:
Test case : All the buttons are initially off and finally the state of only one button has changed so the state of the bulb reverses once i.e. it turns off.
Test case : All the buttons are initially off and finally the states of two buttons have changed so the state of the bulb reverses twice i.e. it remains on.
No comments:
Post a Comment