I encountered some strange difficulty with this problem: https://codeforces.me/contest/1714/submission/293576606. The dp idea is that dp[i] represents the answer for the problem for prefix up to position i. dp[i] takes the longest string with an occurrence ending at position i and then checks the dp answer for all positions within the string occurrence and then the position to the left of the beginning of the string occurrence (quite similar to the tutorial solution). However, I am getting wrong answer on test case 9 still. I don't know quite why...
Could someone take a look at this submission to see what is wrong? https://codeforces.me/contest/1714/submission/293576606 (scroll to bottom for actual code, above is template stuff)