#include <cstdio>
char buffer[200000];
struct ciag
{
int size;
int start_index;
int end_index;
};
typedef struct ciag ciag;
struct data
{
ciag d[200000];
int amount;
};
typedef struct data data;
int getL()
{
int i = 0;
while(buffer[i++]!=0);
return i-1;
}
const char* samogloski = "aeiouy";
int czySamogloska(char c)
{
for(int i =0;i<6;i++)
if(c == samogloski[i])return 1;
return 0;
}
int main()
{
scanf("%s", buffer);
int length = getL();
int last = -1;
int size = 0;
data main;
main.amount = 0;
for(int i =0;i<length;i++)
{
int v = czySamogloska(buffer[i]);
if(v == last){
size++;
}else{
last = v;
if(size >=2)
{
ciag c;
c.start_index = i-size-1;
c.end_index = i-1;
c.size = size+1;
main.amount++;
main.d[main.amount-1] = c;
}
size = 0;
}
if(i == length-1)
{
if(size >=2)
{
ciag c;
c.start_index = i-size;
c.end_index = i;
c.size = size+1;
main.amount++;
main.d[main.amount-1] = c;
}
}
}
int sum = 0;
for(int i =0;i<main.amount;i++)
{
ciag c = main.d[i];
if(c.size == length)sum+=length-1;
else
sum+=((length - 1)-(c.end_index)+1)*(c.start_index + c.size-3+1);
}
printf("%i\n",sum);
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | #include <cstdio> char buffer[200000]; struct ciag { int size; int start_index; int end_index; }; typedef struct ciag ciag; struct data { ciag d[200000]; int amount; }; typedef struct data data; int getL() { int i = 0; while(buffer[i++]!=0); return i-1; } const char* samogloski = "aeiouy"; int czySamogloska(char c) { for(int i =0;i<6;i++) if(c == samogloski[i])return 1; return 0; } int main() { scanf("%s", buffer); int length = getL(); int last = -1; int size = 0; data main; main.amount = 0; for(int i =0;i<length;i++) { int v = czySamogloska(buffer[i]); if(v == last){ size++; }else{ last = v; if(size >=2) { ciag c; c.start_index = i-size-1; c.end_index = i-1; c.size = size+1; main.amount++; main.d[main.amount-1] = c; } size = 0; } if(i == length-1) { if(size >=2) { ciag c; c.start_index = i-size; c.end_index = i; c.size = size+1; main.amount++; main.d[main.amount-1] = c; } } } int sum = 0; for(int i =0;i<main.amount;i++) { ciag c = main.d[i]; if(c.size == length)sum+=length-1; else sum+=((length - 1)-(c.end_index)+1)*(c.start_index + c.size-3+1); } printf("%i\n",sum); return 0; } |
English