#include <iostream>
#include <string>
using namespace std;
int n, i;
string s;
int findDepth()
{
if(s[i] == 'l')
return 0;
i++;
int l = findDepth();
i++;
int r = findDepth();
return max(l, r) + 1;
}
int main()
{
int t;
cin >> t;
cin.get();
while(t--)
{
cin >> s;
n = s.size();
i = 0;
cout << findDepth() << endl;
}
return 0;
}
#include <string>
using namespace std;
int n, i;
string s;
int findDepth()
{
if(s[i] == 'l')
return 0;
i++;
int l = findDepth();
i++;
int r = findDepth();
return max(l, r) + 1;
}
int main()
{
int t;
cin >> t;
cin.get();
while(t--)
{
cin >> s;
n = s.size();
i = 0;
cout << findDepth() << endl;
}
return 0;
}
Comments
Post a Comment