luogu#P8001. Easy Strings Merging
Easy Strings Merging
Problem Description
You are given binary strings. Each time, you may remove one character from the beginning of some string and append it to the end of a new string . Maximize the number of adjacent pairs of equal characters in .
Input Format
The first line contains a positive integer , representing the number of strings.
The next lines each contain a binary string.
Output Format
Output one integer in a single line, representing the answer.
3
0011
0110
1100
9
Hint
Sample Explanation
In an optimal strategy, the indices of the chosen strings at each step are , and the final .
Constraints
This problem uses bundled testdata.
Let be the sum of lengths of the input binary strings.
| Subtask ID | Score | Special Constraints |
|---|---|---|
| , | ||
| , | ||
| , | ||
| No special constraints |
For all testdata, it is guaranteed that .
Translated by ChatGPT 5