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. [PAT] A1020 Tree Traversals

    [题目] distinct 不同的 postorder 后序的 inorder 中序的 sequence 顺序:次序:系列 traversal 遍历 题目大意:给出二叉树的后序遍历和中序遍历,求层次遍 ...

  2. Codeforces Round #617 (Div. 3) 补题记录

    1296A - Array with Odd Sum 题意:可以改变数组中的一个数的值成另外一个数组中的数,问能不能使数组的和是个奇数 思路:签到,如果本来数组的和就是个奇数,那就OK 如果不是,就需 ...

  3. mysql建立索引类型及索引建立的原则

    索引类型:Unique(唯一索引,一般为主键),Normal(一般索引,普通字段,可做组合索引),索引方法:BTREE 1.选择唯一性索引 唯一性索引的值是唯一的,可以更快速的通过该索引来确定某条记录 ...

  4. java学习笔记之IO编程—目录和文件的拷贝

    进行文件或目录的拷贝时,要先判断处理对象是文件还是目录,如果是文件则直接拷贝,如果是目录还需要拷贝它的子目录及其文件,这就需要递归处理了 import java.io.*; class FileUti ...

  5. JS 获取验证码 倒计时

    setInterval 一个定时器搞定 <style> button{ background: #45BCF9; color: #fff; padding: 4px 10px; borde ...

  6. Jmeter-第三方插件安装

    1.插件下载 官方地址https://jmeter-plugins.org/install/Install/ 网盘地址链接: https://pan.baidu.com/s/1E4lnMWDGPWCN ...

  7. 2019-08-18 纪中NOIP模拟A组

    T1 [JZOJ6309] 完全背包 题目描述

  8. JDK 动态代理的实现

    JDK 动态代理的实现 虽然在常用的 Java 框架(Spring.MyBaits 等)中,经常见到 JDK 动态代理的使用,也知道了怎么去写一个 JDK 动态代理的 Demo,但是并不清楚实现原理. ...

  9. 关于npm 的注意事项

    npm install 之后 会生成package-lock.json 文件 ,注意这个文件不能删除,否则每次 npm i 之后,node_modules都装的是最新的,会出现意想不到的问题.

  10. 牛客练习赛53 B题调和级数

    https://ac.nowcoder.com/acm/contest/1114/B 这题时间卡的比较死,多了一个快速幂的logn就过不了这题. #include<bits/stdc++.h&g ...