A10260 | Running Track
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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$ .
输出格式
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$ .
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$ .
输入输出样例
输入 #1
abc cbaabc
输出 #1
2 3 1 1 3
输入 #2
aaabrytaaa ayrat
输出 #2
3 1 1 6 5 8 7
输入 #3
ami no
输出 #3
-1
In the first sample string "cbaabc" = "cba" + "abc".
In the second sample: "ayrat" = "a" + "yr" + "at".
In the second sample: "ayrat" = "a" + "yr" + "at".
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted