#include <stdio.h> #include <time.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <map> #include <string> #include <vector> #include <iostream> #include <sstream> #include <queue> #include <algorithm> #include <assert.h> using namespace std; #define ll long long #define PB push_back #define FOR(a,start,end) for(int a=int(start); a<int(end); a++) #define INF INT_MAX #define SORT(a) sort(a.begin(),a.end()) #define CL(a,x) memset(a,x,sizeof(a)) #define REP(a,x) for(int a=0;a<x;a++) #define REP1(a,x) for(int a=1;a<=x;a++) #define MP make_pair typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vector<int> > vvi; typedef vector<vector<string> > vvs; typedef vector<pair<string, string> > vss; typedef pair<string, string> pss; typedef pair<int, pii> ppii; typedef vector<ppii> vppii; typedef vector<vector<pii> > vvii; typedef vector<vvi> vvvi; ll z; int n, k, a, b, c, i, j, q, t; vi vk, va, vb, vk1, vk2; string w; /* #define LOCAL #ifdef LOCAL #include <time.h> #else #include <sys/time.h> #endif double getTime() { #ifdef LOCAL return ((double)clock() / CLOCKS_PER_SEC); //CPU time on Windows #else timeval t; gettimeofday(&t, NULL); return t.tv_sec + t.tv_usec * 1e-6; //wall clock time on Linux #endif } */ double cz1, cz2; int main() { // freopen( "c:\\wojtek\\uva\\pa\\debug\\ban10.in", "rt", stdin); //pi=2*acos(0.0); //while(1){ //cz1 = getTime(); cin >> w; z = 0; n = w.size(); va.assign(30, 1); vk.assign(n, 0); va[0] = -1; va['e' - 'a'] = -1; va['i' - 'a'] = -1; va['o' - 'a'] = -1; va['u' - 'a'] = -1; va['y' - 'a'] = -1; a = 0; for (int i = 0; i < n - 2; i++) { k = va[w[i] - 'a'] + va[w[i + 1] - 'a'] + va[w[i + 2] - 'a']; if ((k == 3) || (k == -3)) { z += (i - a + 1)*(n - i - 2); a = i + 1; } } cout << z << endl; //cz2 = getTime(); //cerr << cz2 - cz1 << endl; //} return 0; }
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #include <stdio.h> #include <time.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <map> #include <string> #include <vector> #include <iostream> #include <sstream> #include <queue> #include <algorithm> #include <assert.h> using namespace std; #define ll long long #define PB push_back #define FOR(a,start,end) for(int a=int(start); a<int(end); a++) #define INF INT_MAX #define SORT(a) sort(a.begin(),a.end()) #define CL(a,x) memset(a,x,sizeof(a)) #define REP(a,x) for(int a=0;a<x;a++) #define REP1(a,x) for(int a=1;a<=x;a++) #define MP make_pair typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vector<int> > vvi; typedef vector<vector<string> > vvs; typedef vector<pair<string, string> > vss; typedef pair<string, string> pss; typedef pair<int, pii> ppii; typedef vector<ppii> vppii; typedef vector<vector<pii> > vvii; typedef vector<vvi> vvvi; ll z; int n, k, a, b, c, i, j, q, t; vi vk, va, vb, vk1, vk2; string w; /* #define LOCAL #ifdef LOCAL #include <time.h> #else #include <sys/time.h> #endif double getTime() { #ifdef LOCAL return ((double)clock() / CLOCKS_PER_SEC); //CPU time on Windows #else timeval t; gettimeofday(&t, NULL); return t.tv_sec + t.tv_usec * 1e-6; //wall clock time on Linux #endif } */ double cz1, cz2; int main() { // freopen( "c:\\wojtek\\uva\\pa\\debug\\ban10.in", "rt", stdin); //pi=2*acos(0.0); //while(1){ //cz1 = getTime(); cin >> w; z = 0; n = w.size(); va.assign(30, 1); vk.assign(n, 0); va[0] = -1; va['e' - 'a'] = -1; va['i' - 'a'] = -1; va['o' - 'a'] = -1; va['u' - 'a'] = -1; va['y' - 'a'] = -1; a = 0; for (int i = 0; i < n - 2; i++) { k = va[w[i] - 'a'] + va[w[i + 1] - 'a'] + va[w[i + 2] - 'a']; if ((k == 3) || (k == -3)) { z += (i - a + 1)*(n - i - 2); a = i + 1; } } cout << z << endl; //cz2 = getTime(); //cerr << cz2 - cz1 << endl; //} return 0; } |