A8262 | Newspaper Headline
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A newspaper is published in Walrusland. Its heading is $s_{1}$ , it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new word $s_{2}$ . It is considered that when Fangy erases some letter, there's no whitespace formed instead of the letter. That is, the string remains unbroken and it still only consists of lowercase Latin letters.
For example, the heading is "abc". If we take two such headings and glue them one to the other one, we get "abcabc". If we erase the letters on positions $1$ and $5$ , we get a word "bcac".
Which least number of newspaper headings $s_{1}$ will Fangy need to glue them, erase several letters and get word $s_{2}$ ?
For example, the heading is "abc". If we take two such headings and glue them one to the other one, we get "abcabc". If we erase the letters on positions $1$ and $5$ , we get a word "bcac".
Which least number of newspaper headings $s_{1}$ will Fangy need to glue them, erase several letters and get word $s_{2}$ ?
输入格式
The input data contain two lines. The first line contain the heading $s_{1}$ , the second line contains the word $s_{2}$ . The lines only consist of lowercase Latin letters ( $1<=|s_{1}|<=10^{4},1<=|s_{2}|<=10^{6}$ ).
输出格式
If it is impossible to get the word $s_{2}$ in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings $s_{1}$ , which Fangy will need to receive the word $s_{2}$ .
输入输出样例
输入 #1
abc xyz
输出 #1
-1
输入 #2
abcd dabc
输出 #2
2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted