RE-673 Getting wrong answer..can anyone plz help me out.

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Ishraq_Nibir
New poster
Posts: 2
Joined: Fri Mar 10, 2017 10:53 pm

RE-673 Getting wrong answer..can anyone plz help me out.

Post by Ishraq_Nibir » Sun Mar 12, 2017 9:13 pm

#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;
}

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: RE-673 Getting wrong answer..can anyone plz help me out.

Post by lighted » Tue Mar 14, 2017 1:38 pm

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

Post Reply

Return to “Volume 6 (600-699)”