시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
11 초 (추가 시간 없음) | 1024 MB | 35 | 10 | 10 | 28.571% |
Young Anna recently indulges in a word puzzle app on her phone. A word puzzle is a single English word with several blanks. Each blank represents a letter to be filled. For example, the word “programming” may appear as a puzzle p_o_rammin_
. When solving a puzzle, Anna first clicks on a blank and then begins typing letters. The app automatically advances to the next blank once Anna types a letter. When there are no more blanks to the right of the filled letter, the app jumps back to the beginning of the word and advances from there. Anna keeps typing until all blanks are filled. To solve the puzzle p_o_rammin_
, Anna may click on the first blank and type rgg
. Alternatively, she may click on the second blank and then type ggr
.
One day Anna shows you a puzzle that she solved along with the sequence of letters she typed. Could you tell how many different puzzles can be the one that Anna solved? Two puzzles are different if they have blanks at different positions, e.g. if the puzzle word is programming
and Anna typed rgg
, there can be two possible puzzles: p_o_rammin_
and pro__ammin_
. As the answer can be large, output the answer modulo 1,000,000,007.
The first line of input has a single string p giving the puzzle word (1 ≤ |p| ≤ 105). The second line has a single string s giving the letter sequence that Anna typed (1 ≤ |s| ≤ min(50, |p|)). Both strings contain only lowercase English letters.
Output the number of different puzzles that can be the one solved by Anna, modulo 1,000,000,007. If Anna can not have typed s to solve the puzzle, output zero.
programming rgg
2
aabbaa aba
12
acca acac
0
ICPC > Regionals > North America > Mid-Atlantic Regional > 2021 Mid-Atlantic USA Regional Contest I번
ICPC > Regionals > North America > North Central North America Regional > 2021 North Central NA Regional Contest F번