/*judege whether every bracket appears in pairs*/
#include<stdio.h>
#include<string.h>
#define capacity 100
bool is_match(char ch1, char ch2){
return ch1=='('&&ch2==')' || ch1=='['&& ch2==']' || ch1=='{'&&ch2=='}';
}
int main(){
int n, i, top = 0;
char _stack[capacity], quo[capacity];
gets(quo);
n = strlen(quo);
if(quo[0]==')' || quo[0]==']' || quo[0]=='}'){
printf("NO\n");
return 0;
}
_stack[0] = '*';
for(i=0; i<n; i++){
if(is_match(_stack[top], quo[i]))top--;
else _stack[++top] = quo[i];
}
if(top==0)printf("YES\n");
else printf("NO\n");
return 0;
}
#include<stdio.h>
#include<string.h>
#define capacity 100
bool is_match(char ch1, char ch2){
return ch1=='('&&ch2==')' || ch1=='['&& ch2==']' || ch1=='{'&&ch2=='}';
}
int main(){
int n, i, top = 0;
char _stack[capacity], quo[capacity];
gets(quo);
n = strlen(quo);
if(quo[0]==')' || quo[0]==']' || quo[0]=='}'){
printf("NO\n");
return 0;
}
_stack[0] = '*';
for(i=0; i<n; i++){
if(is_match(_stack[top], quo[i]))top--;
else _stack[++top] = quo[i];
}
if(top==0)printf("YES\n");
else printf("NO\n");
return 0;
}