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
#include <iostream>
#include <ctime>
#include <string>

std::string samogloski = "aeiouy";

int ProblemPozycjaPodaj(std::string* tekst, int offset);

int main()
{
	// float timeBegin = std::clock();

	std::string tekst;
	long int problemPozycja = 0;
	long int problemPozycjaPoprzednia = -1;
	unsigned long long int fragmentyIlosc = 0;
	long int tekstDlugosc;
	
	// tekst = "kostka";	
	// tekst = "aaa";
	// tekst = "trdnytst";	 
	// tekst = "abcdefghijklmnopqrstuvwxyz";
	// tekst = "latwytest";
	// tekst = "pvrownasienrt";

    std::cin >> tekst;

	tekstDlugosc = tekst.length();
	long int tekstDlugoscMinus2 = tekstDlugosc - 2;

	for (long int pozycja = 0; pozycja < tekstDlugosc; pozycja++)
	{		
		problemPozycja = ProblemPozycjaPodaj(&tekst, pozycja);

		if (problemPozycja == -1)
			break;

		fragmentyIlosc = 
			fragmentyIlosc 
			+ (
			  (tekstDlugoscMinus2 - problemPozycja)
		   	  * (problemPozycja - problemPozycjaPoprzednia)); 
		
		problemPozycjaPoprzednia = problemPozycja;
		pozycja = problemPozycja;
	}

	std::cout << fragmentyIlosc;

	// std::cout << std::endl << float(clock() - timeBegin) / CLOCKS_PER_SEC;
	// std::cin >> tekst;

	return 0;
}

int ProblemPozycjaPodaj(std::string* tekst, int offset)
{
  long int pozycja = 0;
  int samogloskiIlosc = 0;
  int spolgloskiIlosc = 0;

  int tekstDlugosc = tekst->length();

  for (pozycja = offset; pozycja < tekstDlugosc; pozycja++)
  {	  
	  if (samogloski.find((*tekst)[pozycja]) != std::string::npos)	  
	  {		  
		  spolgloskiIlosc = 0;

		  if (++samogloskiIlosc == 3)
			  break;
	  }
	  else {
		  samogloskiIlosc = 0;
		  if (++spolgloskiIlosc == 3)
			  break;
	  };	  
  }

  if ((samogloskiIlosc == 3) || (spolgloskiIlosc == 3))
	  return pozycja - 2;
  else
	  return -1;
}