#include <bits/stdc++.h> using namespace std; const int maxn = 3e5; typedef long long ll; typedef pair<int, int> Pii; typedef vector<Pii> vpii; typedef vector<int> vi; typedef vector<ll> vll; #define pb push_back #define fst first #define snd second char buff[maxn]; int sam(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { scanf("%s", buff); int n = strlen(buff); ll res = 0; int last_hardy = n; for(int i = n - 3; i >= 0; --i) { int dupa = sam(buff[i]) + sam(buff[i+1]) + sam(buff[i+2]); //printf("%c DUPA = %d\n", buff[i], dupa); if(dupa == 3 || dupa == 0) last_hardy = i + 2; res += n - last_hardy; } printf("%lld\n", res); }
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 | #include <bits/stdc++.h> using namespace std; const int maxn = 3e5; typedef long long ll; typedef pair<int, int> Pii; typedef vector<Pii> vpii; typedef vector<int> vi; typedef vector<ll> vll; #define pb push_back #define fst first #define snd second char buff[maxn]; int sam(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { scanf("%s", buff); int n = strlen(buff); ll res = 0; int last_hardy = n; for(int i = n - 3; i >= 0; --i) { int dupa = sam(buff[i]) + sam(buff[i+1]) + sam(buff[i+2]); //printf("%c DUPA = %d\n", buff[i], dupa); if(dupa == 3 || dupa == 0) last_hardy = i + 2; res += n - last_hardy; } printf("%lld\n", res); } |