Codeforces Round 338 (Div. 2)
C
Running Track
Codeforces
2000
原题
← BD →
翻译中…

A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.

翻译中…

First, he wants to construct the running track with coating $*t*$. On planet AMI-1511 the coating of the track is the sequence of colored blocks, where each block is denoted as the small English letter. Therefore, every coating can be treated as a string.

翻译中…

Unfortunately, blocks aren't freely sold to non-business customers, but Ayrat found an infinite number of coatings $*s*$. Also, he has scissors and glue. Ayrat is going to buy some coatings $*s*$, then cut out from each of them exactly one continuous piece (substring) and glue it to the end of his track coating. Moreover, he may choose to flip this block before glueing it. Ayrat want's to know the minimum number of coating $*s*$ he needs to buy in order to get the coating $*t*$ for his running track. Of course, he also want's to know some way to achieve the answer.

翻译中…

Input

翻译中…

First line of the input contains the string $*s*$ — the coating that is present in the shop. Second line contains the string $*t*$ — the coating Ayrat wants to obtain. Both strings are non-empty, consist of only small English letters and their length doesn't exceed $2100$.

翻译中…

Output

翻译中…

The first line should contain the minimum needed number of coatings $*n*$ or -1 if it's impossible to create the desired coating.

翻译中…

If the answer is not -1, then the following $*n*$ lines should contain two integers $*x*_{*i*}$ and $*y*_{*i*}$ — numbers of ending blocks in the corresponding piece. If $*x*_{*i*} ≤ *y*_{*i*}$ then this piece is used in the regular order, and if $*x*_{*i*} > *y*_{*i*}$ piece is used in the reversed order. Print the pieces in the order they should be glued to get the string $*t*$.

翻译中…

Note

翻译中…

In the first sample string "cbaabc" = "cba" + "abc".

翻译中…

In the second sample: "ayrat" = "a" + "yr" + "at".

翻译中…

样例

Input #1
abc
cbaabc
Output #1
2
3 1
1 3
InputCopy OutputCopy
Input #2
aaabrytaaa
ayrat
Output #2
3
1 1
6 5
8 7
InputCopy OutputCopy
Input #3
ami
no
Output #3
-1
InputCopy OutputCopy
题目信息
题号
615C
时间限制
1 s
内存限制
512 MB
标签
动态规划
贪心
字符串
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。