시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 31 | 15 | 14 | 82.353% |
Jill and Jane are sisters. Last Christmas each of them got a string consisting of colorful beads. We can describe each color as a letter of the English alphabet (“a”. . . “z”), and each string of beads as a word.
The girls would like to create necklaces from their strings. They can turn each string into a necklace by removing some (possibly zero) beads from the ends, and then connecting the ends of the remaining part of the string. The resulting necklace can be rotated and turned over.
The sisters want their necklaces to look exactly the same, and also be as long as possible. What is the maximum length they could achieve?
The first and the second line each contain a non-empty sequence consisting of no more than N lowercase characters, the descriptions of Jill’s and Jane’s strings respectively.
The first line should contain a single positive integer: the maximum number of beads each girl’s necklace can have in the end. It is guaranteed that a positive length can be achieved.
The second line should contain two integers: the starting positions of the necklaces in Jill’s and Jane’s string respectively. If there are several possibilities, output any one of them. The positions are numbered left to right starting from 0.
번호 | 배점 | 제한 |
---|---|---|
1 | 25 | N = 100. |
2 | 20 | N = 400. |
3 | 40 | N = 3000. |
zxyabcd yxbadctz
4 3 2
We can do as follows:
“zxyabcd” → “---abcd” “yxbadctz” → “--badc--”
The strings “abcd” and “badc” result in identical necklaces.