시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 36 | 13 | 12 | 42.857% |
Zenyk bought a string of length n, which contains only 0 and 1 characters. He wants to present it to Marichka, however he knows that she likes only palindromes (strings which read the same backward as forward) and she will be satisfied with just such a gift.
In one hour, Zenyk can change the string by moving any one of its characters to the end of the string. What is the minimum number of hours needed for Zenyk to prepare a gift for Marichka?
The first line contains one integer n (1 ≤ n ≤ 300). The second line contains a string of length n containing only 0 and 1 characters.
If Zenyk succeeds in preparing a gift then print one integer — the minimum number of hours.
If he can’t do that print “-1” (without quotes).
7 1101001
1
4 1001
0
12 110100010011
3