Bit Flipping Game <Nissan>
Practice
3.1 (9 votes)
Basic programming
Bit manipulation
Bit manipulation
Easy
Implementation
Problem
52% Success 9626 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Two players $$A$$ and $$B$$ are playing a game.They are given $$N$$ binary numbers as input. Each binary number is represented as a string of characters '0' or '1'. The string always ends at '1'.  In one move each player decides a bit position $$p$$ . Then he visits all the numbers and if their bit at that position is '1' then he changes it to '0'. It is mandatory to flip(change '1' to '0') bit of atleast one number in each move. The player who is unable to make a move loses. Player $$A$$ begins the game.

Input
First line contains a number $$N$$ as input. Next $$N$$ lines contain a binary string each.

Output
Print A if player A wins , B otherwise. In the next line print the move number of the last move of the winning player.

Constraints
$$1 \le N \le 10^5$$
$$1 \le |S| \le 10^6$$ where $$|S|$$ is sum of length of all bit strings.

 

Some important information - 
Suppose that the length of the string $$S$$ in input is $$K$$ then $$S[0]$$ is the $$0^{th}$$ bit , $$S[1]$$ is the first bit and so on $$S[k - 1]$$ is the $$(k - 1)^{th}$$ bit. All the other bit for that string are assumed as zeros. 

Note: Go through the sample explanation carefully

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
5 votes
Tags:
Basic ProgrammingBit ManipulationBit manipulationEasy
Points:20
156 votes
Tags:
Ad-HocApprovedBit manipulationEasyOpen
Points:20
63 votes
Tags:
ApprovedBasic ProgrammingEasyMathOpen