#K11681. Longest Consecutive Binary Sequence
Longest Consecutive Binary Sequence
Longest Consecutive Binary Sequence
Given a sequence of binary strings, find the longest consecutive sequence of identical binary strings. If multiple sequences have the same length, return the one that appears first in the sequence.
For example, consider the sequence: 110, 110, 001, 001, 001, 101, 101, 101, 101
. The longest consecutive sequence is 101
appearing 4 times, so the answer is (101
, 4).
If the input sequence is empty, output should be None 0
.
Input format: The first line contains an integer n representing the number of binary strings. The following n lines each contain a binary string.
Output format: Output the binary string and its consecutive count separated by a space. If there is no string, output None 0
.
inputFormat
The first line contains an integer n (n ≥ 0) — the number of binary strings. Each of the next n lines contains a binary string (each string consists only of characters '0' and '1').
outputFormat
Print the binary string that has the longest consecutive sequence and the length of that sequence separated by a space. If the input is empty (n = 0), print None 0
.
0
None 0
</p>