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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    string speach;
    cin>>speach;
    int n = (int)speach.size();
    vector<int> word(n);
    vector<int> tab(n);
    long long result = 0;
    for(int i = 0; i < n; i++)
    {
        if(speach[i] == 'a' || speach[i] == 'e' || speach[i] == 'i' || speach[i] == 'o' || speach[i] == 'u' || speach[i] == 'y')
            word[i] = -1;
        else
            word[i] = 1;
    }
    for(int p = 0; p < n; p++)
    {
        //for(int i =0; i<n;i++)tab[i]=0;
        //if(p != 0) tab[p-1] = 0;
        for(int k = p; k < n; k++)
        {
            if(p == k)
                tab[k] = word[p];
            else if(tab[k-1] >= 3 || tab[k-1] <= -3)
            {
                result += (n - k);
                break;
            }
            else
            {
                if(tab[k-1] > 0 && word[k] == 1)
                {
                    tab[k] = 0;
                    tab[k] += tab[k-1] + 1;
                }
                else if(tab[k-1] > 0 && word[k] == -1)
                    tab[k] = -1;
                else if(tab[k-1] < 0 && word[k] == 1)
                    tab[k] = 1;
                else if(tab[k-1] < 0 && word[k] == -1)
                {
                    tab[k] = 0;
                    tab[k] += tab[k-1] - 1;
                }

               // if(p == 1 && k == 3) cout<<tab[k-1]<<endl;
                if(tab[k] >= 3 || tab[k] <= -3)
                {
                    result++;
                }
            }
        }
        //for(int i = 0; i < tab.size(); i++)cout<<tab[i]<<" "; cout<<endl;
    }
    cout<<result<<endl;
}