Page 6 of 8
Getting wrong answer on 494
Posted: Sun Aug 23, 2009 6:25 am
by noor_aub
I have tried all thing. All creatical input and output set. The answer was correct. But I am getting wrong answer. My code is
#include<iostream>
using namespace std;
int main()
{
//freopen("1.txt","r",stdin);
char c;
int count=0,space=1;
while((c=getchar())!=EOF)
{
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
{
if(space)
{
count++;
space=0;
}
}
else if(c=='\n'||c=='\r')
{
cout<<count<<endl;
count=0;
space=1;
}
else
space=1;
}
cout<<count<<endl;
return 0;
}
Re: Getting wrong answer on 494
Posted: Sun Aug 23, 2009 10:39 pm
by mf
* Don't post duplicate messages
* Don't start a new thread, do search for an existing thread on problem 494 and post there.
* Read existing replies in that thread before posting.
* Use [code]...[/code] tags to format source code.
* And in case if you need to start a new thread for a problem, which wasn't yet discussed, follow the convention for thread's title: "<Problem's number> - <Problem's title>". No "Gettign W/A on problem" or anything like that.
Re: 494 Kinder Garden Counting Game WA
Posted: Sun Oct 11, 2009 7:36 am
by noor_aub
If there is two new line what should the program out put 0 or nothing.
Re: 494 WA
Posted: Tue Oct 27, 2009 11:08 pm
by fahim_xubayer
getting Wa
can anyone help please?
Code: Select all
#include<stdio.h>
#include<string.h>
int main(){
unsigned long int a,b,d,x,y,z,l;
char c,m[50000];
while(gets(m)){
l=strlen(m);
b=0;
for(a=0;a<l;a++){
c=m[a];
if(((c<65)||(c>122))||((c>90)&&(c<97)))
continue;
while(((m[a]>65)&&(m[a]<91))||((m[a]>96)&&(m[a]<123))){
if(m[a]==10)
break;
a++;
}
b++;
}
printf("%lu\n",b);
}
return 0;
}
Re: 494 WA
Posted: Wed Nov 04, 2009 9:41 am
by noor_aub
Every Body who have faced W/A in this problem use isalpha function.
It will be lot easier for you.
Re: 494 WA
Posted: Tue Jul 06, 2010 7:16 am
by mehrab
code removed ....
Re: 494 WA
Posted: Tue Jul 06, 2010 7:20 am
by mehrab
1.should the program print 0 for only one letter input?
2.should i print blank line for a blank input or should i print 0?
thnx
Re: 494 WA
Posted: Tue Jul 06, 2010 9:37 pm
by sazzadcsedu
Did yo notice that ->
each line containing multiple words (at least one). A ``word'' is defined as a consecutive sequence of letters (upper and/or lower case).
This means that there is no one letter input(Bcoz it is
not a word, A word is defined as a
consecutive sequence of letters,And each line containing multiple words
(at least one).)
But if you still want to know what is the output of one letter input then i can say my ACC program return 1 for one letter
input.
And your second question is already answered(At least one word in input,no blank line in input).
Re: 494 WA
Posted: Thu Jul 08, 2010 9:34 pm
by mehrab
thnx for da reply ...
but hav u seen my code ... what's wrong there why my code is getting WA
Re: 494 WA
Posted: Fri Jul 09, 2010 9:21 am
by sazzadcsedu
I think ur
tab character does not work correctly.For input
ab<tab>cd<tab>ef
your output produce 1 ,which should be 3.
Re: 494 WA
Posted: Tue Jul 13, 2010 11:14 am
by mehrab
i'm using visual c++ compiler and it is producing correct answer for your input...
does it cause any problem for using two different compilers??
Re: 494 WA
Posted: Tue Jul 13, 2010 8:55 pm
by sazzadcsedu
I am also using visual c++ compiler , But in my compiler
ab<tab>cd<tab>ef
your output produce 1 ,which should be 3.
And your code is no longer in board.So i cant test it again.
494 test my code. why WA?
Posted: Thu Oct 28, 2010 6:53 am
by @mjad
why wrong answer? please help me
Code: Select all
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define M 1000000
int main()
{
//freopen ("494.txt","r",stdin);
char text[M],*t;
int f,i,count,tem;
while(gets(text))
{
count=0;
t=strtok(text," !.,;~!@#$%^&*()\t_\?/\n");
while(t)
{
f=0;
tem=strlen(t);
for(i=0;i<tem;i++)
if(t[i]>='A'&&t[i]<='Z'||t[i]>='a'&&t[i]<='z')
{
f=1;
break;
}
if(f)
count++;
t=strtok(NULL," !.,;~!@#$%^&*()\t_\?/\n");
}
printf("%d\n",count);
}
return 0;
}
Re: 494 WA
Posted: Wed Nov 03, 2010 7:45 pm
by sazzadcsedu
Ok,tell me what will be the output of
your code produce 1.And the correct answer is 2.
Re: 494 WA
Posted: Thu Nov 04, 2010 3:49 am
by @mjad

Thanks for your reply , i got AC