#include<iostream>
#include<stack>
#include<string>
using namespace std;
class Test
{
private:
string str;
stack<char>st;
public:
Test(string str);
bool Judge();
};
int main()
{
while (1) {
string temp;
cin >> temp;
Test A(temp);
cout << A.Judge()<<endl;
}
return 0;
}
Test::Test(string str)
{
this->str = str;
}
bool Test::Judge()
{
for (int i = 0; i < str.length(); i++)
{
if (str[i] == '(' || str[i] == '[' || str[i] == '{')
{
st.push(str[i]);
}
else
{
if (st.empty())
return 0;
char ch = st.top();
if (ch == ')' && str[i] != '(')
return 0;
if (ch == '}' && str[i] != '{')
return 0;
if (ch == ']' && str[i] != '[')
return 0;
st.pop();
}
}
return st.empty();
}
07-09
4298