494 WA

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

Moderator: Board moderators

Re: 494 WA

Postby sazzadcsedu » Wed Nov 03, 2010 7:45 pm

Ok,tell me what will be the output of

Code: Select all
salim1233sazzad

your code produce 1.And the correct answer is 2.
sazzadcsedu
Experienced poster
 
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.

Re: 494 WA

Postby @mjad » Thu Nov 04, 2010 3:49 am

:D Thanks for your reply , i got AC :D
@mjad
New poster
 
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

Re: 494 WA

Postby sibhas » Sun Mar 25, 2012 10:03 pm

The following is my code. It is not getting accepted. I do not know why. I have tried all the test cases and they seem to work fine.

The test cases are
salim1233sazzad

abc abc abc





a

Meep Meep!
I tot I taw a putty tat
I did! I did! I did taw a putty tat ....
Shsssssssssh ... I am hunting wabbits. Heh Heh Heh Heh ....
I tot I taw a putty tat
I did I did I did taw a putty tat
Shsssssssssh I am hunting wabbits Heh Heh Heh Heh

ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz

#include <iostream>
#include <ostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
//freopen("input","r",stdin);
string line;
while(getline(cin,line))
{
int count=0;
if(line.length()>0)
{
int j=0;
while(j<line.length())
{

if ((line[j] >='A' && line[j] <='Z') || (line[j] >='a' && line[j] <='z'))
{
count++;
while ((line[j] >='A' && line[j] <='Z') || (line[j] >='a' && line[j] <='z'))
{

j++;
}
}
else
{
while (!((line[j] >='A' && line[j] <='Z') || (line[j] >='a' && line[j] <='z')))
{
j++;
}
}


}
cout << count << endl;
}

}
return 0;
}
sibhas
New poster
 
Posts: 1
Joined: Sun Mar 25, 2012 9:37 pm

Re: 494 WA

Postby brianfry713 » Tue Mar 27, 2012 11:50 pm

For the sample input, this line is causing a seg fault. You need to check that j<line.length().
while (!((line[j] >='A' && line[j] <='Z') || (line[j] >='a' && line[j] <='z')))
j++
brianfry713
Guru
 
Posts: 1765
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

494 WA - Help Needed

Postby diegon » Fri Jun 08, 2012 10:59 pm

WA: I don't understand what's the problem. :(
I have checked all the inputs in this topic. Any ideas?

Code: Select all
Thanks brianfry713! Got AC
Last edited by diegon on Wed Jun 13, 2012 5:51 am, edited 1 time in total.
diegon
New poster
 
Posts: 3
Joined: Fri Jun 08, 2012 10:45 pm

Re: 494 WA

Postby brianfry713 » Mon Jun 11, 2012 11:39 pm

Input:
,a

AC output:
1
brianfry713
Guru
 
Posts: 1765
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 494 WA

Postby PromeNabid » Mon Jun 18, 2012 1:02 am

My Ac code gives this output...
Input:
Code: Select all
,a
a
The test cases are
salim1233sazzad
abc abc abc
Meep Meep!
I tot I taw a putty tat
I did! I did! I did taw a putty tat ....
Shsssssssssh ... I am hunting wabbits. Heh Heh Heh Heh ....
I tot I taw a putty tat
I did I did I did taw a putty tat
Shsssssssssh I am hunting wabbits Heh Heh Heh Heh
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz


Output:
Code: Select all
1
1
4
2
3
2
7
10
9
7
10
9
2
PromeNabid
New poster
 
Posts: 13
Joined: Mon Jun 18, 2012 12:52 am
Location: Dhaka, Bangladesh.

Re: 494 WA

Postby darksk4 » Fri Aug 03, 2012 6:39 am

Code: Select all
Thanks brianfry713



I dont know why its WA.... hmmmm its maybe my algorithm
Last edited by darksk4 on Sun Aug 05, 2012 8:15 am, edited 1 time in total.
darksk4
New poster
 
Posts: 9
Joined: Sun Jul 29, 2012 7:10 pm

Re: 494 WA

Postby brianfry713 » Fri Aug 03, 2012 11:39 pm

If counter is zero you shouldn't try to read w[counter - 1]
brianfry713
Guru
 
Posts: 1765
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 494 WA

Postby shuvrothpol1 » Wed Sep 12, 2012 1:29 pm

Can anyone help to find out my problem. My code gives the correct answer but i get wa.The code iven below:
#include <stdio.h>
#include <string.h>

int main ()

{
char str[999999];
int i,count;

while (gets (str)){
count=0;
for (i=0;str[i]!='\0';i++)
{if (str[i]==' '&&((str[i+1]>=65&&str[i+1]<=90)||str[i+1]>=97&&str[i+1]<=122))
count++;
else if((str[i]>=33&&str[i]<=64)||(str[i]>=91&&str[i]<=96)||(str[i]>=123&&str[i]<=126))
str[i--]=' ';
}
printf ("%d\n",++count);
}
return 0;
}
shuvrothpol1
New poster
 
Posts: 17
Joined: Wed Aug 15, 2012 12:37 pm

Re: 494 WA

Postby brianfry713 » Wed Sep 12, 2012 8:59 pm

Try input
Code: Select all
,a
brianfry713
Guru
 
Posts: 1765
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 494 WA

Postby alimbubt » Fri Feb 15, 2013 2:07 pm

Some Critical Input That harasses me....
Input:
Code: Select all
,,alim
@@alim0123alim%%alim.
..alim222.. .. .. &&alim
Bangladesh University of Business & Technology
(Alim)(Alim)(Alim)
(Alim) (Alim)()

Output:
Code: Select all
1
3
2
5
3
2
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
alimbubt
New poster
 
Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm
Location: BUBT,Dhaka, Bangladesh

Previous

Return to Volume IV

Who is online

Users browsing this forum: No registered users and 1 guest