1. 程式人生 > >Elimination RoundE】【DP】Intellectual Inquiry 長度為m字串後新增n位最大本質不同子串個數

Elimination RoundE】【DP】Intellectual Inquiry 長度為m字串後新增n位最大本質不同子串個數

After getting kicked out of her reporting job for not knowing the alphabet, Bessie has decided to attend school at the Fillet and Eggs Eater Academy. She has been making good progress with her studies and now knows the firstkEnglish letters.

Each morning, Bessie travels to school along a sidewalk consisting ofm

 + ntiles. In order to help Bessie review, Mr. Moozing has labeled each of the firstmsidewalk tiles with one of the firstklowercase English letters, spelling out a stringt. Mr. Moozing, impressed by Bessie's extensive knowledge of farm animals, plans to let her finish labeling the lastntiles of the sidewalk by herself.

Consider the resulting strings(|s| = m + n) consisting of letters labeled on tiles in order from home to school. For any sequence of indicesp1 < p2 < ... < pqwe can define subsequence of the stringsas stringsp1sp2...spq. Two subsequences are considered to be distinct if they differ as strings. Bessie wants to label the remaining part of the sidewalk such that the number ofdistinct subsequences

of tiles is maximum possible. However, since Bessie hasn't even finished learning the alphabet, she needs your help!

Note that empty subsequence also counts.