CF318B.Strings of Power

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.

Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequence of consecutive characters in a string) in a given text makes our hero especially joyful. Recently he felt an enormous fit of energy while reading a certain text. So Volodya decided to count all powerful substrings in this text and brag about it all day long. Help him in this difficult task. Two substrings are considered different if they appear at the different positions in the text.

For simplicity, let us assume that Volodya's text can be represented as a single string.

沃洛佳喜欢听重金属音乐,也(偶尔)喜欢阅读。难怪他对有关自己最爱音乐风格的文本特别感兴趣。

沃洛佳将一个字符串称为“强力字符串”,当且仅当它以 "heavy" 开头,且以 "metal" 结尾。在给定文本中找出所有“强力子串”(此处“子串”指字符串中连续的一段字符构成的子序列),会让这位英雄格外喜悦。最近,他在阅读某段文本时感到一股巨大的能量涌上心头。于是沃洛佳决定统计该文本中所有强力子串的数量,并为此整整炫耀一整天。请帮助他完成这项艰巨的任务。若两个子串在文本中出现的位置不同,则认为它们是不同的子串。

为简化问题,我们假设沃洛佳的文本可表示为一个单一字符串。

输入格式

Input contains a single non-empty string consisting of the lowercase Latin alphabet letters. Length of this string will not be greater than 106 characters.

输入包含一个非空字符串,该字符串仅由小写拉丁字母组成。该字符串的长度不超过 10610^6 个字符。

输出格式

Print exactly one number — the number of powerful substrings of the given string.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

输出一个整数 —— 给定字符串中强子串(powerful substrings)的数量。

请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符。推荐使用 cin / cout 流,或 %I64d 说明符。

输入输出样例

  • 输入#1

    heavymetalisheavymetal

    输出#1

    3
  • 输入#2

    heavymetalismetal

    输出#2

    2
  • 输入#3

    trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou

    输出#3

    3

说明/提示

In the first sample the string "heavymetalisheavymetal" contains powerful substring "heavymetal" twice, also the whole string "heavymetalisheavymetal" is certainly powerful.

In the second sample the string "heavymetalismetal" contains two powerful substrings: "heavymetal" and "heavymetalismetal".

在第一个样例中,字符串 “heavymetalisheavymetal” 包含强大的子串 “heavymetal” 两次,同时整个字符串 “heavymetalisheavymetal” 当然也是强大的。

在第二个样例中,字符串 “heavymetalismetal” 包含两个强大的子串:“heavymetal” 和 “heavymetalismetal”。

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

首页