Page 1 of 3

10260 - Soundex

Posted: Sat Oct 12, 2002 11:44 am
by Royce Lu
I don't know why I always recieve WA . :cry:
Could someone give me some data?
thanks!! :)


Here is my code :

//@BEGIN_OF_SOURCE_CODE
#include <stdio.h>
void main(){
char array[25];

int i=0;
int printbuffer=0,temp=0;
while(gets(array)){
if(array[0]=='\0')
break;
for(i=0;array!='\0';i++){

if(array=='A'||array=='E'||array=='O')
{temp=0;
continue;}
else if(array=='U'||array=='H'||array=='W'||array=='Y')
{temp=0;
continue;}

else if (array=='C'||array=='G'||array[i]=='J'||array[i]=='K')
{printbuffer=2;}
else if(array[i]=='Q'||array[i]=='S'||array[i]=='X'||array[i]=='Z')
{printbuffer=2;}

else if (array[i]=='B'||array[i]=='F'||array[i]=='P'||array[i]=='V')
{printbuffer=1;}
else if (array[i]=='D'||array[i]=='T')
{printbuffer=3;}
else if (array[i]=='M'||array[i]=='N')
{printbuffer=5;}
else if (array[i]=='L')
{printbuffer=4;}
else if (array[i]=='R')
{printbuffer=6;}

if(printbuffer==temp)
continue;
else{
printf("%d",printbuffer);
temp=printbuffer;
}

}
printf("\n");
}

}

//@END_OF_SOURCE_CODE

Re: 10260,HELP!

Posted: Tue Nov 05, 2002 4:35 pm
by uzioriluzan
This is a problem from Waterloo. Maybe you could find something helpful there.
Regards!
Royce Lu wrote:I don't know why I always recieve WA . :cry:
Could someone give me some data?
thanks!! :)


Here is my code :

//@BEGIN_OF_SOURCE_CODE
#include <stdio.h>
void main(){
char array[25];

int i=0;
int printbuffer=0,temp=0;
while(gets(array)){
if(array[0]=='\0')
break;
for(i=0;array!='\0';i++){

if(array=='A'||array=='E'||array=='O')
{temp=0;
continue;}
else if(array=='U'||array=='H'||array=='W'||array=='Y')
{temp=0;
continue;}

else if (array=='C'||array=='G'||array[i]=='J'||array[i]=='K')
{printbuffer=2;}
else if(array[i]=='Q'||array[i]=='S'||array[i]=='X'||array[i]=='Z')
{printbuffer=2;}

else if (array[i]=='B'||array[i]=='F'||array[i]=='P'||array[i]=='V')
{printbuffer=1;}
else if (array[i]=='D'||array[i]=='T')
{printbuffer=3;}
else if (array[i]=='M'||array[i]=='N')
{printbuffer=5;}
else if (array[i]=='L')
{printbuffer=4;}
else if (array[i]=='R')
{printbuffer=6;}

if(printbuffer==temp)
continue;
else{
printf("%d",printbuffer);
temp=printbuffer;
}

}
printf("\n");
}

}

//@END_OF_SOURCE_CODE

Posted: Tue Nov 12, 2002 7:44 pm
by deddy one
can anyone give me sample input/output data
what is the output for
A
ASDQWER
VBDSUEQPQOPQWEXXCZ


thx

Posted: Fri Dec 13, 2002 6:43 am
by rjhadley
The output should be:

2326
132212122

10260 Soundex Why WA

Posted: Sun Feb 09, 2003 11:53 am
by shamim
Could some one tell me why I get WA:


/* @begin_of_source_code */

#include<string.h>
#include<stdio.h>
int main(void)
{
char code[6][9];
char word[20];
int len,i,j;
strcpy(code[0],"BFPV");
strcpy(code[1],"CGJKQSXZ");
strcpy(code[2],"DT");
strcpy(code[3],"L");
strcpy(code[4],"MN");
strcpy(code[5],"R");

while(scanf("%s",word)!=EOF)
{
len=strlen(word);
for(i=0;i<len;i++)
{
for(j=0;j<6;j++)
{
if(strchr(code[j],word))
{
printf("%d",j+1);
if(i<len-1)
while(strchr(code[j],word))
{ i++; if(i>=len) break; }
else break;
if(i>=len) break;
j=0;
}
}
}
printf("\n");
}
return 0;
}
/* @end_of_source_code */

Posted: Thu Feb 13, 2003 5:19 am
by Red Scorpion
Hai, Try this test Cases :
sample input:
AADDAAGJ
KKLPA
KL
OP
PPPPAOAOOOAOOSDF
MMNBGDF
AAPQOW
ZZZZX
XXZ
PPPQOHIAKL
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZXY
HIJKL
MNOPAS
QRTS
APA

Sampe Output:
32
241
24
1
1231
51231
12
2
2
1224
1231224512623122
2
24
512
2632
1

8) 8)
GOOD LUCK!

Posted: Fri Feb 21, 2003 7:44 pm
by Jalal
try by this:
char code[6][20];
in place of
char code[6][9];
and increase the size of word

10260 Why W.A

Posted: Sat Sep 25, 2004 9:59 am
by efr_shovo
Please Help me Why 10260 Gives Wrong ans.


#include<stdio.h>
#define MAX 300

char s[MAX];
char str[1000];
int i;
char ch;
void main()
{

s['B']='1';
s['F']='1';
s['P']='1';
s['V']='1';

s['C']='2';
s['G']='2';
s['J']='2';
s['K']='2';
s['Q']='2';
s['S']='2';
s['X']='2';
s['Z']='2';

s['D']='3';
s['T']='3';

s['L']='4';

s['M']='5';
s['N']='5';

s['R']='6';

while(gets(str))
{
while(str)
{

if(ch!=s[str]&&s[str]!='\0')

putchar(s[str]);
ch=s[str];
i++;
}
printf("\n");
i=0;
}
}

Posted: Tue May 31, 2005 11:00 pm
by jaracz
thanks for I/O!
It was very useful for me!!;)

10260 - Soundex why got WA

Posted: Fri Jul 29, 2005 8:17 pm
by shaikat
Can anyone help about 10260. I have got WA. I have post the code below:

Code: Select all

#include<stdio.h>



char al[255];
int i,memory,flag;
char str[85];

void main()
{

	//freopen("C:\\IN.TXT","r",stdin);
	//freopen("C:\\OUT1.TXT","w",stdout);


	al['A']='\0';
	al['B']='1';
	al['C']='2';
	al['D']='3';al['E']='\0';al['F']='1';al['G']='2';al['H']='\0';
	al['I']='\0';al['J']='2';al['K']='2';al['L']='4';al['M']='5';al['N']='5';
	al['O']='\0';al['P']='1';al['Q']='2';al['R']='6';al['S']='2';al['T']='3';
	al['U']='\0';al['V']='1';al['W']='\0';al['X']='2';al['Y']='\0';al['Z']='2';

	while(scanf("%s",str)!=EOF)
	{
		flag=0;
		i=0;
		while(str[i])
		{
			if(flag==0)
			{
				for(;al[str[i]]=='\0';i++);
				memory=al[str[i]]-48;
				putchar(al[str[i]]);
				flag=1;
			}
			if(al[str[i]]!='\0')
			{
				if(memory!=al[str[i]]-48)
					{putchar(al[str[i]]);memory=al[str[i]]-48;}
			}
			else
				memory=-1;
			i++;

		}
		if(flag!=0)
			printf("\n");

	}
}
pls help me........... :)

Modified but Still got WA

Posted: Wed Aug 03, 2005 7:18 pm
by shaikat
I have modified the code in the following way. But I still got WA.


Code: Select all

#include<stdio.h>


char al[255];
int i,memory,flag;
char str[85];

void main()
{

	freopen("C:\\in.txt","r",stdin);
	freopen("C:\\OUT1.TXT","w",stdout);


	al['A']='\0';
	al['B']='1';
	al['C']='2';
	al['D']='3';al['E']='\0';al['F']='1';al['G']='2';al['H']='\0';
	al['I']='\0';al['J']='2';al['K']='2';al['L']='4';al['M']='5';al['N']='5';
	al['O']='\0';al['P']='1';al['Q']='2';al['R']='6';al['S']='2';al['T']='3';
	al['U']='\0';al['V']='1';al['W']='\0';al['X']='2';al['Y']='\0';al['Z']='2';

	while(scanf("%s",str)!=EOF)
	{
		flag=0;
		i=0;
		while(str[i])
		{
			/*if(flag==0)
			{
				for(;al[str[i]]=='\0';i++);
				memory=al[str[i]]-48;
				putchar(al[str[i]]);
				flag=1;
			} */
			if(al[str[i]]!='\0')
			{
				if(memory!=al[str[i]]-48)
					{putchar(al[str[i]]);memory=al[str[i]]-48;}
			}
			else
				memory=-1;
			i++;

		}
		/*if(flag!=0)*/
			printf("\n");

	}
}
pls help me.................................. :D :(

10260 - plzzzzzzzzzzzzzz help

Posted: Tue Aug 09, 2005 8:37 pm
by shaikat
Any one pls help me why i got WA.

Code: Select all

#include<stdio.h> 


char al[255]; 
int i,memory,flag; 
char str[85]; 

void main() 
{ 

//   freopen("C:\\in.txt","r",stdin); 
  // freopen("C:\\OUT1.TXT","w",stdout); 


   al['A']='\0'; 
   al['B']='1'; 
   al['C']='2'; 
   al['D']='3';al['E']='\0';al['F']='1';al['G']='2';al['H']='\0'; 
   al['I']='\0';al['J']='2';al['K']='2';al['L']='4';al['M']='5';al['N']='5'; 
   al['O']='\0';al['P']='1';al['Q']='2';al['R']='6';al['S']='2';al['T']='3'; 
   al['U']='\0';al['V']='1';al['W']='\0';al['X']='2';al['Y']='\0';al['Z']='2'; 

   while(scanf("%s",str)!=EOF) 
   { 
      flag=0; 
      i=0; 
      while(str[i]) 
      { 
         if(al[str[i]]!='\0') 
         { 
            if(memory!=al[str[i]]-48) 
               {putchar(al[str[i]]);memory=al[str[i]]-48;} 
         } 
         else 
            memory=-1; 
         i++; 

      } 
         printf("\n"); 

   } 
} 

Re: 10260 - plzzzzzzzzzzzzzz help

Posted: Thu Aug 11, 2005 2:52 am
by tan_Yui
Hi, shaikat.
After checking the following input, try to debugging :)

Input :

Code: Select all

KHAWN
PFISTER
BOBBY
AADDAAGJ
KKLPA
KL
OP
PPPPAOAOOOAOOSDF
MMNBGDF
AAPQOW
ZZZZX
XXZ
PPPQOHIAKL
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZXY
HIJKL
MNOPAS
QRTS
APA
Output should be :

Code: Select all

25
1236
11
32
241
24
1
1231
51231
12
2
2
1224
1231224512623122
2
24
512
2632
1
(This input set are written in old log of this board, and checked again using my code now. Thanks!)

Best regards.

thanks

Posted: Thu Aug 11, 2005 9:00 pm
by shaikat
Many many thanks tan_Yui. At last, i have got AC.

Thanks again.

-shaikat :D

10260

Posted: Mon Dec 05, 2005 2:48 pm
by abhi
here is my code i get WA..... i have tried the test cases mentioned in this site and i seem to be getting the right ans .........

Code: Select all

#include<stdio.h>


int main()
{
	char s[100],c;
	int a=0,n=0;
   
	s['B']=1;s['F']=1;s['P']=1;s['V']=1;
	s['C']=2;s['G']=2;s['J']=2;s['K']=2;s['Q']=2;s['S']=2;s['X']=2;s['Z']=2;
	s['D']=3;s['T']=3;
	s['L']=4;
	s['M']=5;s['N']=5;
	s['R']=6;
	while((c=getchar())!=EOF)

	{
	  if(c==10){printf("\n");	continue;}
	  n=s[c];
		if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U'||c=='H'||c=='W'||c=='Y')
			{
				a=n;
				continue;
         }
		else if(n!=a)
			{
			printf("%d",s[c]);
			a=n;
			}
		

	}
return 0;
}