시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 33 | 15 | 10 | 38.462% |
You are given a string $s$ consisting of zeros (0
), ones (1
), and question marks (?
).
The number of question marks in $s$ is exactly $a + b$.
Replace $a$ question marks with zeros and $b$ question marks with ones to obtain a binary string $t$. Let $f(t)$ be the length of the longest substring of $t$ consisting of equal digits (e.g. 11111
or 0000
).
Your task is to minimize $f(t)$.
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^5$). Description of the test cases follows.
The first line of each test case contains three integers $n$, $a$, and $b$ ($1 \le n \le 250\,000$; $0 \le a$; $0 \le b$).
The second line contains a string $s$ of length $n$ consisting of characters 0
, 1
, and ?
. The number of question marks in $s$ is equal to $a + b$.
It is guaranteed that the sum of $n$ over all test cases does not exceed $250\,000$.
For each test case, print two lines.
In the first line, print a single integer $f(t)$, denoting the smallest possible length of the longest substring of $t$ consisting of equal digits.
In the second line, print any string $t$ achieving this value of $f(t)$ itself.
4 7 1 2 0?01??0 10 5 0 ?000??0?0? 11 0 0 11001110100 15 2 4 ?1?11?1??11100?
1 0101010 10 0000000000 3 11001110100 4 110111101111001