{"raw_statement":[{"iden":"statement","content":"****Note: The memory limit for this problem is 512MB, twice the default.****  \n\nAfter years of hosting games and watching Bessie get first place over and over, Farmer John has realized that this can't be accidental. Instead, he concludes that Bessie must have winning coded into her DNA so he sets out to find this \"winning\" gene.  \n\nHe devises a process to identify possible candidates for this \"winning\" gene. He takes Bessie's genome, which is a string $S$ of length $N$ where $1 \\leq N \\leq 3000$. He picks some pair $(K,L)$ where $1 \\leq L \\leq K \\leq N$ representing that the \"winning\" gene candidates will have length $L$ and will be found within a larger $K$ length substring. To identify the gene, he takes all $K$ length substrings from $S$ which we will call a $k$-mer. For a given $k$-mer, he takes all length $L$ substrings, identifies the lexicographically minimal substring as a winning gene candidate (choosing the leftmost such substring if there is a tie),  and then writes down the $0$-indexed position $p_i$ where that substring starts in $S$ to a set $P$.   \n\nSince he hasn't picked $K$ and $L$ yet, he wants to know how many candidates there will be for every pair of $(K,L)$.  \n\nFor each $v$ in $1\\dots N$, help him determine the number of $(K,L)$ pairs with $|P|=v$."},{"iden":"input","content":"$N$ representing the length of the string. $S$ representing the given string. All characters are guaranteed to be uppercase characters where $s_i \\in A-Z$ since bovine genetics are far more advanced than ours."},{"iden":"output","content":"For each $v$ in $1\\dots N$, output the number of $(K,L)$ pairs with $|P|=v$, with each number on a separate line."},{"iden":"note","content":"In this test case, the third line of the output is 5 because we see that there are exactly 5 pairs of $K$ and $L$ that allow for three \"winning\" gene candidates.  These candidates are (where $p_i$ is $0$-indexed):  \n```text\n(4,2) -> P = [0,3,4]\n(5,3) -> P = [0,3,4]\n(6,4) -> P = [0,3,4]\n(6,5) -> P = [0,1,3]\n(6,6) -> P = [0,1,2]\n```\nTo see how (4,2) leads to these results, we take all $4$-mers \n```text\nAGTC\nGTCA\nTCAA\nCAAC\nAACG\n```\nFor each $4$-mer, we identify the lexicographically minimal length 2 substring \n```text\nAGTC -> AG\nGTCA -> CA\nTCAA -> AA\nCAAC -> AA\nAACG -> AA\n```\nWe take the positions of all these substrings in the original string and add them to a set $P$ to get $P = [0,3,4]$.  \n\nOn the other hand, if we focus on the pair $(4,1)$, we see that this only leads to $2$ total \"winning\" gene candidates. If we take all $4$-mers and identify the lexicographically minimum length $1$ substring (using A and A' and A* to distinguish the different As), we get \n```text\nAGTC -> A\nGTCA' -> A'\nTCA'A* -> A'\nCA'A*C -> A'\nA'A*CG -> A'\n```\nWhile both A' and A* are lexicographically minimal in the last 3 cases, the leftmost substring takes precedence so A' is counted as the only candidate in all of these cases. This means that $P = [0,4]$.  \n\n\n#### SCORING:\n\n- Inputs 2-4: $N \\leq 100$ \n- Inputs 5-7: $N \\leq 500$ \n- Inputs 8-16: No additional constraints."}],"translated_statement":null,"sample_group":[["8\nAGTCAACG","11\n10\n5\n4\n2\n2\n1\n1"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}