No.1005 Anti-BOT Measures
Problem Statement
On a certain social network, there are accounts called 'BOT' that automatically react and reply when a posted text contains a specific word.
A BOT reacts when the posted text contains $T$ as a contiguous substring.
SF-kun is about to post a text represented by the string $S$.
Since SF-kun does not want the BOT to react,
he has decided to insert the character '.' at suitable positions in $S$ so that the BOT does not react.
Determine whether it is possible to keep the BOT from reacting, and if it is possible, find
the minimum number of '.' characters that must be inserted to keep it from reacting.
Input
$S$ $T$
[Constraints]
・$S,\ T$ are strings of lowercase English letters with length at least $1$ and at most $1000$
Output
If it is impossible to keep the BOT from reacting, output '-1'.
If it is possible, output the minimum number of '.' characters that must be inserted.
Sample
Sample 1
Input
doyouknowsegmenttreeiknowsegmenttree segmenttree
Output
2
If posted as is, $S$ contains "segmenttree" as a contiguous substring, so the BOT will react.
For example, you can insert the character '.' at two positions, turning
$S$ into "doyouknowsegment.treeiknowsegment.tree".
Inserting at one position or fewer cannot prevent the reaction, so this is the answer.
Sample 2
Input
youaretouristofworldofwakingup zekki
Output
0
The BOT does not react even without any insertion.
Sample 3
Input
sumomomomomomomomonouchi momo
Output
4
For example, with "sumo.mom.omom.omom.omonouchi", the BOT does not react.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
eSeF
tatyam