Stringology
Time limit1sMemory limit1024 MB
For each i from 0 to n-1, find the longest prefix of s, shorter than n, that is a suffix of pre(s, i) + t.
- Level
Medium7 of 10
- Topics
- String, String matching
- Solved
- No attempts yet
Problem
For a string , denotes the prefix . Likewise, denotes the suffix . Both and are empty strings.
For two strings and , denotes the concatenation . Also,
Given two strings and , let . Find .
Input
The input consists of several test cases, ending at end-of-file. Each test case has two lines. The first line contains the string , and the second line contains the string .
Output
For each test case, output integers .
Constraints
. Each and is a lowercase letter from a to z. In each input, the sum of is at most .
Hint
For the second case, .
So .