Algorithm


Problem Name: 2 AD-HOC - beecrowd | 1876

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1876

Rabiola

 

By Ricardo Martins, IFSULDEMINAS BR Brazil

Timelimit: 1

Every year, residents of the city of Pipacicaba organize the municipal championship kites. In this place, they use a special type of vine to use as Rabiola the kite. The vine is formed of a single strand formed by normal leaves and adherent sheets. In the examples, normal sheets are represented by a letter 'o' and the adherent sheets formed by a letter 'x'. To take advantage of the various colors of vines, each championship kite can just put a single tape. Each adhesive sheet to be stuck at a single point in the kite base. With this, normal leaves fillets are formed. The two outermost fillets are normally without folds. Internal fillets, always formed by an even number of leaves are bent: Below is an example of vine, and their placement in the kite:

Vine: ooxooooooxo

After pasting the adhesive sheets, the Rabiola looks like this:

Fillets appear separated in the image for better viewing. In fact, the threads are superimposed. Its mission is to make an algorithm that, given a vine, enter the size of the largest Rabiola fillet done with it.

 

Input

 

The entry has multiple test cases . Each test case is given in one row containing a word composed only of the letters P 'o' and 'x' represents a vine . This word has no more than 100 characters. The entry ends with the end of the file .

 

Output

 

For each test case , print a line containing a single integer N , which is the size of the largest Rabiola fillet formed by this vine.

 

 

 

Input Sample Output Sample

oxooooxo

ooxooooooxo

oooxooooxo

2

3

3

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <bits/stdc++.h>

using namespace std;

int main()
{
	string s;
	
	while (cin >> s)
	{
		int temx = 0;
		int qtde = 0;
		int mx = INT_MIN;
		
		for (int i = 0; i  <  s.size(); ++i)
		{
			if (s[i] != 'x')
				++qtde;
			else
			{
				if (temx == 0)
				{
					mx = max(mx, qtde);
					temx = 1;
				}
				else mx = max(mx, qtde / 2);
				qtde = 0;
			}
		}
		mx = max(mx, qtde);
		cout << mx << '\n';
	}
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
oxooooxo
ooxooooooxo
oooxooooxo

Output

x
+
cmd
2
3
3
Advertisements

Demonstration


Previous
#1867 Beecrowd Online Judge Solution 1867 The Greater One-digit Number Solution in C, C++, Java, Js and Python
Next
#1877 Beecrowd Online Judge Solution 1877 Sansa's Snow Castle Solution in C, C++, Java, Js and Python