#include <iostream>
#include <cstdio>
using namespace std;
#define LLI long long int
#define REDB cout << "\033[1;31m";
#define REDE cout << "\033[0m";
int n, tab[200100];
LLI wynik;
char s[200100];
bool samogloska (char c)
{
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return true;
else return false;
}
//*********************************************************************************************
int main()
{
scanf(" %s", s);
for(int i = 0; s[i] != NULL; i++) {
n++;
if (i != 0 && samogloska(s[i-1]) == samogloska(s[i])) tab[i] = tab[i-1] + 1;
else tab[i] = 1;
}
int ost = -1;
for(int i = 0; i < n; i++) {
if (tab[i] >= 3)
wynik += ((LLI)n - (LLI)i) * ((LLI)i - 2ll - (LLI)ost),
ost = i - 2;
}
printf("%lld\n", wynik);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <iostream> #include <cstdio> using namespace std; #define LLI long long int #define REDB cout << "\033[1;31m"; #define REDE cout << "\033[0m"; int n, tab[200100]; LLI wynik; char s[200100]; bool samogloska (char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return true; else return false; } //********************************************************************************************* int main() { scanf(" %s", s); for(int i = 0; s[i] != NULL; i++) { n++; if (i != 0 && samogloska(s[i-1]) == samogloska(s[i])) tab[i] = tab[i-1] + 1; else tab[i] = 1; } int ost = -1; for(int i = 0; i < n; i++) { if (tab[i] >= 3) wynik += ((LLI)n - (LLI)i) * ((LLI)i - 2ll - (LLI)ost), ost = i - 2; } printf("%lld\n", wynik); } |
English