#P10920. 宇宙射线
宇宙射线
Background
Thanks to
Cosmic rays change things all the time /fn.
Problem Description
Given a binary string of length , you need to find the longest substring whose length is even and whose first half is exactly the same as its second half.
However, due to cosmic ray attacks on this string, the values at some positions have become unknown.
You may treat each unknown value as either or . Under this condition, find the length of the longest such substring.
This problem has multiple test cases.
Input Format
The first line contains a positive integer , the number of test cases.
The next lines describe the test cases, where every two lines form one test case. For each test case, the first line contains a positive integer , the length of the string, and the next line contains a string of length .
Output Format
Output lines. Each line contains a non-negative integer, the answer for the -th test case. Since the length of the substring must be even, you only need to output the result of dividing its length by .
2
10
0110011010
6
01?0?0
4
3
Hint
This problem uses bundled tests.
| Score | Special Property | ||
|---|---|---|---|
| No special constraints | |||
| No special constraints | |||
: It is guaranteed that contains no character ?.
It is guaranteed that the string consists only of the three characters 0, 1, and ?, and that .
Translated by ChatGPT 5