string abcdcdab

The new queen of Zing Dynasty is The Queen K oliliKo .
She is very fond of her name.
She orders everyone in Zing to present her a KOLILIKO string.

A string is called KOLILIKO string if it follows the following conditions-
• It can be sliced into exactly four parts of equal length. ( KO LI LI KO )
• The first part is identical to the last part.
• The second part is identical to the third part.

Little Fuji also has a string and wants to present it to Queen but he doesn’t know whether it’s a KOLILIKO string or not.

Help Fuji to present his string to the queen at a minimum cost.

Following are rules/costs to manipulate any string in Zing:-

• Characters of any particular part can be shuffled within that part without any cost.

• Characters cannot be transferred from one part to another.

• Replacing any character of the string with a new one costs 1 Unit .

INPUT:-

The first line of input contains a positive integer Q denoting the number of Queries.

The first line of each query contains a positive integer L denoting the length of the string.

The next line of the query contains a string of length L.

OUTPUT:-

Print “YES” (without quotes) if there is no cost to convert the string to KOLILIKO String.

Else print “NO” (without quotes) followed by an integer denoting the minimum cost.

CONSTRAINTS

1≤Q≤100000

4≤L≤200000

(L is always a multiple of 4)

String only consists of lower case letters of the english alphabets.

Sum of L over all queries ≤1000000

SAMPLE INPUT

2 4 abcd 8 abcdcdab

SAMPLE OUTPUT

NO 2 YES

Explanation

The first string is obviously not a KOLILIKO String. The minimum cost to convert it into KOLILIKO String is 2. One of the ways is to change c to b and d to a . The resulting String will be abba.

The second string is already a KOLILIKO String.

So u hav jst copy pasted the prob statement
thanks but we already hav so many probs here on codechef
dont you think you shld give little explanation abt what u did to solve it and where are u stuck
@psaini72 this what I was talking about
no explanation, no interaction, no self input

@ganesh92
Yes I agree, 99% of Discuss is like this

@phoenix0203
Don’t just copy paste the whole problem statement. Provide a link to the problem statement instead. Make sure the problem is not from an ongoing contest. Share your progress on this problem so far. It will be much better if you ask for hints rather that a solution so that you figure it out yourself ( you have asked for neither ).

@ganesh92 and @psaini72 i’ll keep this in mind .And i have solved this .Thanks a lot .

1 Like