#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define Maxsize 10
typedef char elemtype;
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode Stack;
typedef struct Node
{
elemtype ch;
Stack next;
}Node;
Stack CreateStack(void)
{
Stack s;
s = (Stack)malloc(sizeof(Node));
if(!s)
printf("Out Of Space\n");
s->next = NULL;
return s;
}
int IsEmpty(Stack s)
{
if(s->next == NULL)
return 0; //0代表栈为空
return 1; //1代表栈非空
}
void Push(Stack s,elemtype x)
{
while(s->next != NULL)
{
s = s->next;
}
//s->ch = x;
Stack tmp;
tmp = (Stack)malloc(sizeof(Node));
if(!tmp)
{
printf("Out of space\n");
exit(1);
}
tmp->ch = x;
s->next = tmp;
tmp->next = NULL;
}
elemtype Top(Stack s)
{
if(!IsEmpty(s))
{
printf("栈以空\n");
return NULL;
}
while(s->next->next != NULL)
{
s = s->next;
}
elemtype x = s->next->ch;
free(s->next);
s->next = NULL;
return x;
}
void MakeEmpty(Stack s)
{
if(!IsEmpty(s))
free(s);
while(s!=NULL)
{
while(!s->next->next == NULL)
{
free(s->next);
s->next = NULL;
}
}
}
int main(void)
{
Stack s;
s = CreateStack();
char a[Maxsize];
while(scanf("%s",a)!=EOF)
{
int len = strlen(a);
for(int i=0;i < len;i ++)
{
if(a[i] == '(' || a[i] == '[' || a[i] == '{')
Push(s,a[i]);
if(a[i] == ')' || a[i] == ']' || a[i] == '}')
{
char ch = Top(s);
if(a[i] == '}'&&ch != '{')
{
printf("No\n");
i = len;
}
if(a[i] == ']'&&ch != '[')
{
printf("No\n");
i = len;
}
if(a[i] == ')'&&ch != '(')
{
printf("No\n");
i = len;
}
}
}
if(!IsEmpty(s))
printf("Yes\n");
else
printf("No\n");
}
return 0;
}