#include<bits/stdc++.h>
using namespace std;
string s;
stack<char> stk;
int main(){
	cin>>s;
	if(s=="()["||s=="[]("){
		cout<<"NO";
	}else{
		for(int i=0;i<s.size();i++){
		char c=s[i];
		if(c=='('||c=='['){
			stk.push(c);
		}else{
			if(stk.empty()==1){
				cout<<"NO";
				return 0;
			}
			stk.pop();
		}
	}
	if(stk.empty()==1) cout<<"YES";
	else cout<<"NO";
	}
	return 0;
}

0 comments

No comments so far...

Information

ID
2098
Time
1000ms
Memory
256MiB
Difficulty
8
Tags
(None)
# Submissions
80
Accepted
10
Uploaded By