Recall that string aa is a subsequence of a string bb if aa can be obtained from bb by deletion of several (possibly zero or all) characters. For example, for the string aa="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 ss, compute and output its wow factor. Note that it is not guaranteed that it is possible to get ss from another string replacing "w" with "vv". For example, ss can be equal to "vov".

Input

The input contains a single non-empty string ss, consisting only of characters "v" and "o". The length of ss is at most 106106.

Output

Output a single integer, the wow factor of ss.

Examples
input

Copy
vvvovvv
output

Copy
4
input

Copy
vvovooovovvovoovoovvvvovovvvov
output

Copy
100
Note

The first example is explained in the legend.


刚开始忘了两个int相加还是int,只用了一个longlong的sum,导致溢出。

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const int maxn = 1e5 + ;
const long long inf = 0x7f7f7f7f7f7f7f7f; int main()
{
string s;
cin >> s;
int v = , maxn = , initial = , firsto = ;
vector<ll> dp;
for (int i = ; s[i] == 'v'; i++)
initial++;
if (initial > )
dp.push_back(initial - );
else
dp.push_back();
for (int i = initial+; i < s.size(); i++)
{
if (s[i] == 'v')
maxn++;
else
{
if (maxn > )
dp.push_back(dp.back() + maxn - );
else
dp.push_back(dp.back());
maxn = ;
}
if (i == s.size() - && maxn>)
{
dp.push_back(dp.back() + maxn - );
} } ll sum = ;
for (int i = ; i < dp.size(); i++)
{
sum += (dp.back() - dp[i])*dp[i];
}
cout << sum;
return ;
}

WOW Factor的更多相关文章

  1. Codeforces Global Round 4 B. WOW Factor (前缀和,数学)

    题意:找出序列中有多少子序列是\(wow\),但是\(w\)只能用\(vv\)来表示. 题解:我们分别记录连续的\(v\)和\(o\)的个数,用\(v1\)和\(v2\)存,这里要注意前导\(o\)不 ...

  2. Codeforces 1178B. WOW Factor

    传送门 显然对每个 $o$ ,考虑左边和右边分别有多少 $w$,那么这个 $o$ 的贡献就是左右 $w$ 的出现次数相乘 $w$ 的出现次数可以直接根据每一段连续的 $v$ 得到 那么从左到右扫一遍, ...

  3. (转)iOS Wow体验 - 第八章 - 易用性与自动化技术

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第八章译文精选,也是全书译文的最后一篇.上一篇:W ...

  4. (转)iOS Wow体验 - 第七章 - 操作图例与触屏人机工学

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第七章译文精选,其余章节将陆续放出.上一篇:Wow ...

  5. (转)iOS Wow体验 - 第六章 - 交互模型与创新的产品概念(2)

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第六章译文精选的第二部分,其余章节将陆续放出.上一 ...

  6. (转)iOS Wow体验 - 第六章 - 交互模型与创新的产品概念(1)

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第六章译文精选,其余章节将陆续放出.上一篇:Wow ...

  7. (转)iOS Wow体验 - 第五章 - 利用iOS技术特性打造最佳体验

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第五章译文精选,其余章节将陆续放出.上一篇:Wow ...

  8. (转)iOS Wow体验 - 第四章 - 为应用的上下文环境而设计

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第四章译文精选,其余章节将陆续放出.上一篇:Wow ...

  9. (转)iOS Wow体验 - 第三章 - 用户体验的差异化策略

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第三章译文精选,其余章节将陆续放出.上一篇:Wow ...

随机推荐

  1. Web APIs---2. DOM(1)

    1 DOM简介 1.1 定义 DOM就是文档对象模型,是W3C组织推荐的处理可扩展标记语言(HTML或者XML)的标准编程接口.W3C已经定义了一系列的DOM接口,通过这些DOM接口可以改变网页的内容 ...

  2. vue.js中用npm安装vue-router时报错处理办法

    当在使用npm安装东西的时候,最怕遇到的就是,电脑并不想和你说话,只向你抛出一大堆错误...比如在vue.js中用npm安装vue-router的时候,我就遇到 一脸蒙逼的我默默的念了一句:卧..槽. ...

  3. Leetocode7道买卖股票问题总结(121+122+123+188+309+901+714)

    题目1----121. 买卖股票的最佳时机I: 链接:https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/ 给定一个数组, ...

  4. std::ref和std::cref使用(转载)

    转载于:https://blog.csdn.net/lmb1612977696/article/details/81543802 std::ref和std::cref 解释: std::ref 用于包 ...

  5. The sklearn preprocessing

    Recently, I was writing module of feature engineering, i found two excellently packages -- tsfresh a ...

  6. Spark学习之路 (一)Spark初识 [转]

    官网介绍 什么是Spark 官网地址:http://spark.apache.org/ Apache Spark™是用于大规模数据处理的统一分析引擎. 从右侧最后一条新闻看,Spark也用于AI人工智 ...

  7. 数据结构KMP算法中手算next数组

    总结一下今天的收获(以王道数据结构书上的为例子,虽然我没看它上面的...):其中竖着的一列值是模式串前缀和后缀最长公共前缀. 最后求得的结果符合书上的结果,如果是以-1开头的话就不需要再加1,如果是以 ...

  8. Ubuntu使用ipython出现版本不兼容的问题

    今天租了一个ECS,然后准备安装了jupyter,准备配置,输入ipython,出现如下报错 ImportError: IPython 7.10+ supports Python 3.6 and ab ...

  9. 项目打jar包和运行

    打包成jar包和部署,运行. 1.在pom.xml中加入  <packaging>jar</packaging> <groupId>com.demo02</g ...

  10. ActiveMQ的p2p模式与发布订阅模式

    1.消息中间件:采用异步通讯防止,支持点对点以及发布订阅模式,可以解决高并发问题        传统调用接口,可能发生阻塞,重复提交,超时等等问题,可以利用消息中间件发送异步通讯请求          ...