CF1178B.WOW Factor
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Recall that string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly zero or all) characters. For example, for the string a="wowwo", the following strings are subsequences: "wowwo", "wowo", "oo", "wow", "", and others, but the following are not subsequences: "owoo", "owwwo", "ooo".
The wow factor of a string is the number of its subsequences equal to the word "wow". Bob wants to write a string that has a large wow factor. However, the "w" key on his keyboard is broken, so he types two "v"s instead.
Little did he realise that he may have introduced more "w"s than he thought. Consider for instance the string "ww". Bob would type it as "vvvv", but this string actually contains three occurrences of "w":
- "vvvv"
- "vvvv"
- "vvvv"
For example, the wow factor of the word "vvvovvv" equals to four because there are four wows:
- "vvvovvv"
- "vvvovvv"
- "vvvovvv"
- "vvvovvv"
Note that the subsequence "vvvovvv" does not count towards the wow factor, as the "v"s have to be consecutive.
For a given string s, compute and output its wow factor. Note that it is not guaranteed that it is possible to get s from another string replacing "w" with "vv". For example, s can be equal to "vov".
回忆一下,若字符串 a 可通过从字符串 b 中删除若干(可能为零个或全部)字符而得到,则称 a 是 b 的一个子序列。例如,对于字符串 a="wowwo",以下字符串均为其子序列:“wowwo”、“wowo”、“oo”、“wow”、""(空字符串)等;但以下字符串不是其子序列:“owoo”、“owwwo”、“ooo”。
一个字符串的 “wow 因子”(wow factor)是指该字符串中等于单词 "wow" 的子序列的个数。Bob 想要写出一个 wow 因子很大的字符串。然而,他键盘上的 "w" 键坏了,因此每当他想输入 "w" 时,就输入两个 "v" 来代替。
他未曾意识到,这样操作可能意外地引入了比预期更多的 "w"。例如,字符串 "ww" 会被他输入为 "vvvv",而该字符串实际上包含了三个 "w":
- "vvvv"
- "vvvv"
- "vvvv"
再比如,字符串 "vvvovvv" 的 wow 因子等于 4,因为其中存在四个 "wow":
- "vvvovvv"
- "vvvovvv"
- "vvvovvv"
- "vvvovvv"
注意:子序列 "vvvovvv" 不计入 wow 因子,因为构成 "w" 的两个 "v" 必须是连续的。
给定一个字符串 s,请计算并输出它的 wow 因子。注意:题目不保证 s 一定可由某个原始字符串通过将每个 "w" 替换为 "vv" 得到。例如,s 可能直接等于 "vov"。
输入格式
The input contains a single non-empty string s, consisting only of characters "v" and "o". The length of s is at most 106.
输入包含一个非空字符串 s,该字符串仅由字符 “v” 和 “o” 组成。字符串 s 的长度至多为 106。
输出格式
Output a single integer, the wow factor of s.
输出一个整数,即字符串 s 的“wow 因子”。
输入输出样例
输入#1
vvvovvv
输出#1
4
输入#2
vvovooovovvovoovoovvvvovovvvov
输出#2
100
说明/提示
The first example is explained in the legend.
第一个示例在图例中进行了说明。
输入解题思路,AI测评打分。不知道怎么写?