#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n;
string s;
k=1;
while(1)
{
cin>>s;
if(s[0]=='-')
break;
else
{
stack<char>st;
for(i=0;i<s.size();i++)
{
if(st.empty())
{
st.push(s[i]);
continue;
}
if(st.top()=='{'&&s[i]=='}')
{
st.pop();
continue;
}
else
{
st.push(s[i]);
}
}
ll cnt1=0;
ll cnt2=0;
while(!st.empty())
{
if(st.top()=='{')
{
cnt1++;
}
else
{
cnt2++;
}
st.pop();
}
ll cnt;
if(cnt1%2==0)
{
cnt1/=2;
}
else
{
cnt1=(cnt1/2)+1;
}
if(cnt2%2==0)
{
cnt2/=2;
}
else
{
cnt2=(cnt2/2)+1;
}
cnt=cnt1+cnt2;
cout<<k<<". "<<cnt<<endl;
k++;
}
}
return 0;
}
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n;
string s;
k=1;
while(1)
{
cin>>s;
if(s[0]=='-')
break;
else
{
stack<char>st;
for(i=0;i<s.size();i++)
{
if(st.empty())
{
st.push(s[i]);
continue;
}
if(st.top()=='{'&&s[i]=='}')
{
st.pop();
continue;
}
else
{
st.push(s[i]);
}
}
ll cnt1=0;
ll cnt2=0;
while(!st.empty())
{
if(st.top()=='{')
{
cnt1++;
}
else
{
cnt2++;
}
st.pop();
}
ll cnt;
if(cnt1%2==0)
{
cnt1/=2;
}
else
{
cnt1=(cnt1/2)+1;
}
if(cnt2%2==0)
{
cnt2/=2;
}
else
{
cnt2=(cnt2/2)+1;
}
cnt=cnt1+cnt2;
cout<<k<<". "<<cnt<<endl;
k++;
}
}
return 0;
}
No comments:
Post a Comment