1 #include<iostream> 2 #include<cstring> 3 #include<stack> 4 using namespace std; 5 6 stack<char> sta; 7 8 bool match(){ 9 string s; 10 cin>>s; 11 for(int i=0;i<s.length();i++){ 12 if(s[i]==‘(‘||s[i]==‘[‘)sta.push(s[i]); 13 else if(s[i]==‘)‘){ 14 if(!sta.empty()&&sta.top()==‘(‘)sta.pop(); 15 else return 0; 16 }else{ 17 if(!sta.empty()&&sta.top()==‘[‘)sta.pop(); 18 else return 0; 19 } 20 } 21 if(sta.empty())return 1; 22 else return 0; 23 } 24 int main(){ 25 if(match())cout<<"OK"; 26 else cout<<"Wrong"; 27 return 0; 28 }