#include <stdio.h>
#include <string.h>
int main()
{
int n,i,j,k,l,count,mount,len,first,third;
char str[130];
scanf("%d",&n);
getchar();
for(i=0;i<n;i++){
gets(str);
len=strlen(str);
count=0;mount=0;first=0;third=0;
for(j=0;j<len;j++){
if(str[j]=='('){
first=1;
break;
}
if(str[j]==')'){
first=3;
break;
}
}
for(j=0;j<len;j++){
if(str[j]=='['){
third=1;
break;
}
if(str[j]==']'){
third=3;
break;
}
}
if(first!=3&&third!=3){
for(j=0;j<len;j++){
if(str[j]=='(')
count++;
if(str[j]==')')
count--;
if(str[j]=='[')
mount++;
if(str[j]==']')
mount--;
}
if(count==0&&mount==0)
printf("Yes\n");
else
printf("No\n");
}
else
printf("No\n");
}
return 0;
}
RE-673 Getting wrong answer..can anyone plz help me out.
Moderator: Board moderators
-
- New poster
- Posts: 2
- Joined: Fri Mar 10, 2017 10:53 pm
Re: RE-673 Getting wrong answer..can anyone plz help me out.
Don't double post. Post in existing thread.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman