Page 3 of 4
Posted: Sun Dec 10, 2006 2:03 am
by mf
Your program wrongly says 'YES' to this test:
Posted: Sun Dec 10, 2006 2:33 am
by Kire Sopov
Thank you for the quick reply. I got an AC
Anyway, the fix is to just add the line:
else if (nValids == 0) return false;
after this line:
else if (it == ss.end()) return (nValids == 0);
in the function CheckValids() in my previous post.
Posted: Sun Dec 10, 2006 10:05 am
by little joey
Please remove your code after getting AC.
Posted: Mon Mar 05, 2007 11:59 am
by algoJo
INPUT
Code: Select all
cpCpp
zpCpp
Cppzp
a
p
NpEpqNNNp
CDEIpqrstu
CDEINpqrst
CDENINpqrst
OUTPUT
are those right?
can anyone give me some critical I/O..
thanks...
Posted: Mon Mar 05, 2007 2:28 pm
by Jan
Mt accepted code returns
Output:
Hope it helps.
Posted: Thu Sep 27, 2007 6:01 pm
by rhsumon
Why RTE.......... I mean All r right.......... Plz chack some one
Posted: Thu Sep 27, 2007 6:42 pm
by helloneo
Input description says..
assume that each sentence has at most 256 characters and at least 1 character
So, you may have to increase the size of the array..
Posted: Thu Sep 27, 2007 8:12 pm
by rhsumon
Oh shittt what a silly mistake
Thnx for help
!!!!!!!!!!!!!!!!!!!
Re: 271 - WA
Posted: Wed May 27, 2009 4:40 pm
by calicratis19
Re: 271 - WA why ???
Posted: Wed Sep 12, 2012 9:44 pm
by sonjbond
i m getting WA
my code is here
#include<stdio.h>
#include<string.h>
int main()
{
int i,j,k,len, a,b,c,m,n,t,kase,sum;
char sen[300];
while(gets(sen))
{
len=strlen(sen);
int s=0;
int n=0;
int c=0;
if(len==1&&sen[0]>='p'&&sen[0]<='z')printf("YES");
else if(sen[len-1]>='p'&&sen[len-1]<='z'&&sen[len-2]=='N')
{
for(i=0; i<len-1; i++)
{
if(sen=='N')n++;
}
if(n==len-1)printf("YES");
else printf("NO");
}
else if(sen[len-1]>='p'&&sen[len-1]<='z'&&sen[len-2]>='p'&&sen[len-2]<='z')
{
if(len==3&&(sen[len-3]=='C'||sen[0]=='D'||sen[0]=='E'||sen[0]=='I'))
printf("YES");
else
{
n=0;
for(i=0; i<len-2; i++)
{
if(sen=='N')
n++;
}
if((sen[i-1]=='C'||sen[i-1]=='D'||sen[i-1]=='E'||sen[i-1]=='I')&&(n==len-3))
printf("YES");
else printf("NO");
}
}
else printf("NO");
printf("\n");
}
return 0;
}
plz help ! help!! help!!
Re: 271 - WA
Posted: Thu Sep 13, 2012 8:33 pm
by brianfry713
For the input posted by algoJo in this thread, your code doesn't match the output posted by Jan.
Re: 271 - WA, i get WA, somebody help me
Posted: Tue Oct 29, 2013 12:48 am
by tridorje
brianfry713 wrote:For the input posted by algoJo in this thread, your code doesn't match the output posted by Jan.
Re: 271 - WA
Posted: Tue Oct 29, 2013 10:11 pm
by brianfry713
Input zN output should be NO
Re: 271 - WA
Posted: Fri Nov 01, 2013 5:20 am
by tridorje
brianfry713 wrote:Input zN output should be NO
Thank you very much

Re: 271 - WA
Posted: Sun Dec 29, 2013 2:12 pm
by prasad6443
Hi all,
Can anyone help in fixng .....I am getting Wrong answer for the following code...Thanks in advance...
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
char *str = (char *)malloc(300*sizeof(char));
struct stack
{
char c;
struct stack *next;
};
void push(struct stack **top , char c1)
{
struct stack *newnode = (struct stack *)malloc(sizeof(struct stack));
if(newnode)
{
newnode -> c = c1;
newnode -> next = *top;
}
*top = newnode;
}
void pop(struct stack **top) //No need to return popped element
{
(*top) = (*top) -> next;
}
int isStackEmpty(struct stack *top)
{
return (top == NULL)?1:0;
}
int stacksize(struct stack * top)
{
int i=0;
while(!isStackEmpty(top))
{
pop(&top);
++i;
}
return i;
}
int main()
{
struct stack *top = NULL;
int len, i;
bool FLAG = false;
while(gets(str))
{
if(FLAG)
cout<<endl;
FLAG = true;
len = strlen(str);
for(i = len-1;i>=0;i--)
{
if(str >= 'p' && str <= 'z')
push(&top , str);
else if(str == 'N')
{
if(stacksize(top) >= 1)
{
pop(&top);
push(&top , str);
}
else
{
cout<<"NO";
break; //Stack is empty and Ns syntax is not found
}
}
else if(str == 'C' || str == 'D' || str == 'E' || str == 'I')
{
if(!isStackEmpty(top))
{
if(stacksize(top) >= 2)
{
pop(&top);
pop(&top);
push(&top , str);
}
else
{
cout<<"NO";
break; //Stack is empty and Ns syntax is not found
}
}
}
else
{
cout<<"NO";
break;
}
} //FOR END
if(i == -1 && stacksize(top) == 1)
cout<<"YES";
if(i== -1 && stacksize(top) != 1)
cout<<"NO";
top = NULL; //Making stack empty*/
}// WHILE END
return 0;
}