Last active
July 30, 2019 22:25
-
-
Save Rockbet/28c101d53013e3ffdc7d3b645873bd66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1e6+100; | |
long long prefixo[maxn], sufixo[maxn]; | |
int main(){ | |
string s; | |
cin >> s; | |
long long resposta = 0; | |
for(int i=1; i<s.size(); i++){ // Precalcular quantidade de 'w's no meu prefixo. | |
prefixo[i]=prefixo[i-1]; | |
if(s[i]=='v' and s[i-1]=='v'){ | |
prefixo[i]++; | |
} | |
} | |
for(int i=s.size()-2; i>=0; i--){ // Precalcular quantidade de 'w's no meu sufixo. | |
sufixo[i]=sufixo[i+1]; | |
if(s[i]=='v' and s[i+1]=='v'){ | |
sufixo[i]++; | |
} | |
} | |
for(int i=0; i<s.size(); i++){ // Calcular a resposta. | |
if(s[i]=='o'){ | |
resposta += (sufixo[i])*(prefixo[i]); | |
} | |
} | |
cout << resposta << endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment