#include <iostream> #include <cstdio> #include <set> #include <algorithm> #include <string> using namespace std; #define LONG long long //#define LONG __int64 char* c1 = 0; char* c2 = 0; char* c3 = 0; char* c4 = 0; set<char> setC; LONG llresult = 0LL; void Add() { long lspan = c3 - c2 - 2L; LONG llfromleft = 1LL * (c2 - c1 + 1L); LONG llfromright = 1LL * (c4 - c2 - 2L); LONG lln = 1LL * (c4 - c3 + 1L); llresult += llfromleft * llfromright; if(lspan > 1L) { --llfromright; llresult += ((llfromright - lln + 1LL) * (lln + llfromright)) / 2LL; } c1 = c3; --c1; --c1; } char IsVowel(char* cp) { if(setC.find(*cp) != setC.end()) return 'a'; return 'x'; } void ReadInput() { char* indata = 0; indata = new char[200001]; cin.getline(indata, 200001); c1 = indata; c2 = c1; c3 = c1; long left = cin.gcount() - 1; while(left--) { *c2 = IsVowel(c2); ++c2; } c4 = c2; c2 = c1; while(c3 != c4) { ++c3; if(*c3 != *c2) { if(c3 - c2 > 2) Add(); c2 = c3; } } if(c3 - c2 > 2) Add(); } int main(int argc, char* argv[]) { setC.insert('a'); setC.insert('e'); setC.insert('i'); setC.insert('o'); setC.insert('u'); setC.insert('y'); ReadInput(); printf("%lld\n", llresult); 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 | #include <iostream> #include <cstdio> #include <set> #include <algorithm> #include <string> using namespace std; #define LONG long long //#define LONG __int64 char* c1 = 0; char* c2 = 0; char* c3 = 0; char* c4 = 0; set<char> setC; LONG llresult = 0LL; void Add() { long lspan = c3 - c2 - 2L; LONG llfromleft = 1LL * (c2 - c1 + 1L); LONG llfromright = 1LL * (c4 - c2 - 2L); LONG lln = 1LL * (c4 - c3 + 1L); llresult += llfromleft * llfromright; if(lspan > 1L) { --llfromright; llresult += ((llfromright - lln + 1LL) * (lln + llfromright)) / 2LL; } c1 = c3; --c1; --c1; } char IsVowel(char* cp) { if(setC.find(*cp) != setC.end()) return 'a'; return 'x'; } void ReadInput() { char* indata = 0; indata = new char[200001]; cin.getline(indata, 200001); c1 = indata; c2 = c1; c3 = c1; long left = cin.gcount() - 1; while(left--) { *c2 = IsVowel(c2); ++c2; } c4 = c2; c2 = c1; while(c3 != c4) { ++c3; if(*c3 != *c2) { if(c3 - c2 > 2) Add(); c2 = c3; } } if(c3 - c2 > 2) Add(); } int main(int argc, char* argv[]) { setC.insert('a'); setC.insert('e'); setC.insert('i'); setC.insert('o'); setC.insert('u'); setC.insert('y'); ReadInput(); printf("%lld\n", llresult); return 0; } |