#include<bits/stdc++.h>
using namespace std;
int main(){
	stack<char> s;
	string a;
	cin>>a;
	int len=a.size();
	for(int i=0;i<len;i++){
		if(a[i]=='(' || a[i]=='[') s.push(a[i]);
		else{
			if(a[i]==')' && s.top()=='(') s.pop();
			else if(a[i]==']' && s.top()=='[') s.pop();
			else{
				cout<<"Wrong";
				return 0;
			}
		}
	}if(s.empty()) cout<<"OK";
	else cout<<"Wrong";
	return 0;
}

0 条评论

目前还没有评论...

信息

ID
355
时间
ms
内存
MiB
难度
2
标签
递交数
192
已通过
60
上传者