問題一覧 > 通常問題

No.1005 Anti-BOT Measures

レベル : / AI推定難易度 : 625 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 308
作問者 : eSeF / テスター : tatyam
お気に入りにしたユーザー ProblemId : 4007 / 自分の提出
問題文最終更新日: 2020-03-03 02:31:43
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 240 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。