View difference between Paste ID: 6MWhg4ZV and XqDQvBYN
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
using namespace std;
3
const int MAX=255;
4
char a[MAX], s[MAX];
5
int k=0;
6
int main() {
7
	cin>>s;
8
	for(int i = 0; i <strlen(s); i++) {
9
		if ((s[i]=='(' || s[i]=='[' || s[i]=='{') && k<MAX) a[++k]=s[i];
10
		if ((s[i]==')' && a[k]=='(' || s[i]==']' && a[k]=='[' || s[i]=='}' && a[k]=='{') && k>=1) k--;
11
	}
12-
	if (k) cout<<"no"; else cout<<"yes";
12+
	if (k==0) cout<<"no"; else cout<<"yes";
13
	return 0;
14
}