Let the string be SS.

Hint 1

Hint 2

Hint 3

Hint 4

Solution 1

Solution 2

Solution 3

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!