CF625B.War of the Corporations

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.

This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineapple did their best to postpone the release of Lastus 3000 as long as possible. Finally, they found out, that the name of the new artificial intelligence is similar to the name of the phone, that Pineapple released 200 years ago. As all rights on its name belong to Pineapple, they stand on changing the name of Gogol's artificial intelligence.

Pineapple insists, that the name of their phone occurs in the name of AI as a substring. Because the name of technology was already printed on all devices, the Gogol's director decided to replace some characters in AI name with "#". As this operation is pretty expensive, you should find the minimum number of characters to replace with "#", such that the name of AI doesn't contain the name of the phone as a substring.

Substring is a continuous subsequence of a string.

很久以前,在遥远的银河系中,两家巨型IT企业——菠萝公司(Pineapple)与谷歌公司(Gogol)——持续展开激烈竞争。关键性时刻即将到来:谷歌公司即将发布其全新平板电脑“Lastus 3000”。

这款新设备配备了一种专门设计的人工智能(AI)。菠萝公司的员工竭尽全力,试图尽可能推迟“Lastus 3000”的发布。最终,他们发现:该人工智能的新名称与菠萝公司200年前发布的一款手机名称非常相似。由于该手机名称的所有权完全归属于菠萝公司,因此菠萝公司坚持要求谷歌公司更改其人工智能的名称。

菠萝公司坚持认为:其手机名称必须作为子串(substring)出现在人工智能名称中。然而,由于人工智能名称已印制在所有设备上,谷歌公司主管决定:用字符 # 替换人工智能名称中的若干字符。由于该替换操作成本高昂,你需要找出最少需要替换多少个字符,使得人工智能名称中不再包含手机名称作为子串。

子串(substring)指字符串中一个连续的子序列。

输入格式

The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.

输入的第一行包含戈果尔设计的 AI 的名称,其长度不超过 100 000 个字符。第二行包含 200 年前菠萝公司发布的手机名称,其长度不超过 30。两个字符串均非空,且仅由小写英文字母组成。

输出格式

Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.

打印为使手机名称不在AI名称中作为子串出现,必须替换为“#”的最少字符数。

输入输出样例

  • 输入#1

    intellect
    tell

    输出#1

    1
  • 输入#2

    google
    apple

    输出#2

    0
  • 输入#3

    sirisiri
    sir

    输出#3

    2

说明/提示

In the first sample AI's name may be replaced with "int#llect".

In the second sample Gogol can just keep things as they are.

In the third sample one of the new possible names of AI may be "s#ris#ri".

在第一个样例中,AI 的名称可以替换为 “int#llect”。

在第二个样例中,果戈里只需保持原状即可。

在第三个样例中,AI 的一个可能的新名称是 “s#ris#ri”。

输入解题思路,AI测评打分。不知道怎么写?

首页