271 - Simply Syntax

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

Moderator: Board moderators

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sun Dec 10, 2006 2:03 am

Your program wrongly says 'YES' to this test:

Code: Select all

pCp

Kire Sopov
New poster
Posts: 7
Joined: Wed Sep 15, 2004 2:01 am

Post by Kire Sopov » Sun Dec 10, 2006 2:33 am

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.

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Sun Dec 10, 2006 10:05 am

Please remove your code after getting AC.

User avatar
algoJo
New poster
Posts: 37
Joined: Sun Dec 17, 2006 9:02 am

Post by algoJo » Mon Mar 05, 2007 11:59 am

INPUT

Code: Select all

cpCpp
zpCpp
Cppzp
a
p
NpEpqNNNp
CDEIpqrstu
CDEINpqrst
CDENINpqrst
OUTPUT

Code: Select all

NO
YES
NO
NO
YES
YES
NO
YES
YES
are those right?
can anyone give me some critical I/O..
thanks...

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Mon Mar 05, 2007 2:28 pm

Mt accepted code returns

Output:

Code: Select all

NO
NO
NO
NO
YES
NO
NO
YES
YES
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

rhsumon
New poster
Posts: 48
Joined: Wed Aug 23, 2006 12:29 pm
Location: Dhaka

Post by rhsumon » Thu Sep 27, 2007 6:01 pm

Why RTE.......... I mean All r right.......... Plz chack some one

Code: Select all

Code Removed after AC..........
Last edited by rhsumon on Thu Sep 27, 2007 8:19 pm, edited 1 time in total.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo » Thu Sep 27, 2007 6:42 pm

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..

rhsumon
New poster
Posts: 48
Joined: Wed Aug 23, 2006 12:29 pm
Location: Dhaka

Post by rhsumon » Thu Sep 27, 2007 8:12 pm

Oh shittt what a silly mistake
Thnx for help
!!!!!!!!!!!!!!!!!!!

calicratis19
Learning poster
Posts: 76
Joined: Mon Jul 21, 2008 8:50 am
Location: SUST,SYLHET,BANGLADESH.
Contact:

Re: 271 - WA

Post by calicratis19 » Wed May 27, 2009 4:40 pm

AC. some of my frnds and my code has same problem. we just had to handle the case for 'N' specially. then ac. but the same condition for 'N' i gave when i checked it with other 4 char : D,I ,E, C. dont know why i get WA then. :o :o :o :o
Heal The World

sonjbond
New poster
Posts: 19
Joined: Wed Jul 04, 2012 10:30 pm

Re: 271 - WA why ???

Post by sonjbond » Wed Sep 12, 2012 9:44 pm

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!!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 271 - WA

Post by brianfry713 » Thu Sep 13, 2012 8:33 pm

For the input posted by algoJo in this thread, your code doesn't match the output posted by Jan.
Check input and AC output for thousands of problems on uDebug!

tridorje
New poster
Posts: 8
Joined: Wed Oct 02, 2013 3:23 am

Re: 271 - WA, i get WA, somebody help me

Post by tridorje » Tue Oct 29, 2013 12:48 am

brianfry713 wrote:For the input posted by algoJo in this thread, your code doesn't match the output posted by Jan.

Code: Select all

remove
Last edited by tridorje on Fri Nov 01, 2013 5:22 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 271 - WA

Post by brianfry713 » Tue Oct 29, 2013 10:11 pm

Input zN output should be NO
Check input and AC output for thousands of problems on uDebug!

tridorje
New poster
Posts: 8
Joined: Wed Oct 02, 2013 3:23 am

Re: 271 - WA

Post by tridorje » Fri Nov 01, 2013 5:20 am

brianfry713 wrote:Input zN output should be NO
Thank you very much :)

prasad6443
New poster
Posts: 1
Joined: Sun Dec 29, 2013 2:05 pm

Re: 271 - WA

Post by prasad6443 » Sun Dec 29, 2013 2:12 pm

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

Post Reply

Return to “Volume 2 (200-299)”