[Problem](https://mirror.codeforces.com/contest/2086/problem/F)↵
↵
I want to explain the brute force for F.↵
↵
In the tutorial of F,it said "however, deriving them manually is quite complicated, as there are many situations."↵
↵
But I consider this problem as a perfect chance to practice case work:↵
↵
Do the first three letters by case work.↵
↵
First, whether $s_1$ is 'a' or 'b' doesn't matter.↵
↵
We can just record the longest 'ababab' prefix and the value of $s_{mid}$ ,and do case work. Do two letters $x,y$ once.↵
↵
1. p=1; p is odd number ;p is even number↵
2. $s_1=s_{mid}$,$s_1\neq s_{mid}$↵
3. $p=mid-1$,$p\neq mid-1$↵
4. $x=a$,$x=b$↵
5. $y=a$,$y=b$↵
↵
In the $p=1$,we don't care $p=mid-1$.↵
↵
As in the code,there is $2\times 2 \times 2+2\times 2\times 2\times 2\times 2=40$ cases,handle them one by one and get c++ code in 15kb.↵
↵
I highly recommend youto reading [code](https://mirror.codeforces.com/contest/2086/submission/314486386), and I'm glad you to find my mistakes.
↵
I want to explain the brute force for F.↵
↵
In the tutorial of F,it said "however, deriving them manually is quite complicated, as there are many situations."↵
↵
But I consider this problem as a perfect chance to practice case work:↵
↵
Do the first three letters by case work.↵
↵
First, whether $s_1$ is 'a' or 'b' doesn't matter.↵
↵
We can just record the longest 'ababab' prefix and the value of $s_{mid}$ ,and do case work. Do two letters $x,y$ once.↵
↵
1. p=1; p is odd number ;p is even number↵
2. $s_1=s_{mid}$,$s_1\neq s_{mid}$↵
3. $p=mid-1$,$p\neq mid-1$↵
4. $x=a$,$x=b$↵
5. $y=a$,$y=b$↵
↵
In the $p=1$,we don't care $p=mid-1$.↵
↵
As in the code,there is $2\times 2 \times 2+2\times 2\times 2\times 2\times 2=40$ cases,handle them one by one and get c++ code in 15kb.↵
↵
I highly recommend you



