1178B.md (1815B)
1 Source: https://codeforces.com/problemset/problem/1178/B 2 3 B. WOW Factor 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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". 22 23 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. 24 25 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": 26 27 * "vvvv" 28 * "vvvv" 29 * "vvvv" 30 31 For example, the wow factor of the word "vvvovvv" equals to four because there are four wows: 32 33 * "vvvovvv" 34 * "vvvovvv" 35 * "vvvovvv" 36 * "vvvovvv" 37 38 Note that the subsequence "vvvovvv" does not count towards the wow factor, as the "v"s have to be consecutive. 39 40 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". 41 42 Input 43 44 The input contains a single non-empty string $s$, consisting only of characters "v" and "o". The length of $s$ is at most $10^6$. 45 46 Output 47 48 Output a single integer, the wow factor of $s$. 49 50 Examples 51 52 Input 53 54 ``` 55 vvvovvv 56 ``` 57 58 Output 59 60 ``` 61 4 62 ``` 63 64 Input 65 66 ``` 67 vvovooovovvovoovoovvvvovovvvov 68 ``` 69 70 Output 71 72 ``` 73 100 74 ``` 75 76 Note 77 78 The first example is explained in the legend.