Page 2 of 3

Posted: Fri Feb 17, 2006 10:37 am
by Ankur Kumar Nayak
Sorry for troubling.....Got my code accepted finally....just a minor bug....

sorry i don't know your program..

Posted: Fri Mar 03, 2006 8:36 am
by sds1100
sorry i don't know your program..
sorry.sorry.sorry.sorry.sorry.

Posted: Wed Dec 06, 2006 5:24 pm
by anala_sridhar
i have tried with Farid Ahmadov's test input (above) and got the same output but still got the code rejected (WA) in Java.


can someone please help me with more sample input texts.

according to the problem statement, single characters ARE Ananagrams.
In that case, what should be the output for the
Input
  • A a a A
    B b B
    C c
thanks in adv
sridhar

Posted: Thu Jan 04, 2007 1:23 pm
by rickyliu
anala_sridhar, I can send you the input/output if you provide a email address. Single letter words are relative anangrams but the input used by the judge seems not to have such cases. My AC program does not print out anything from your input.

Posted: Thu Jan 04, 2007 4:33 pm
by anala_sridhar
thanks a lot for the reply. Can you please send the input/output to the mailid anala.sridhar@gmail.com .

thanks again
sridhar

Posted: Fri Jan 05, 2007 6:15 am
by rickyliu
Please check your mail box.

Posted: Wed Feb 21, 2007 1:06 pm
by beloni
Hello,

Can I read the input for this problem this way?

Code: Select all

char dic[MAX_DIC][MAX_DIC];
while(true)
	{
		cin >> dic[i];
		if( dic[i][0] == '#' )
			break;
		else
			i++;
	}
If no, why? Thanks.

Posted: Sat Feb 24, 2007 12:00 pm
by ranban282
I think you can.

Posted: Thu Mar 08, 2007 7:06 pm
by beloni
Thanks, did works and I got AC!
For those who want help, my ACed code outputs:
beloni@hopcroft:~/programming/judge/ananagram_156_0$ cat ananagram.in2
A a a A a a B B B C Hello HELLO Hi REpLy
ladder came tape soon leader acme RIDE lone Dreis peat
ScAlE orb eye Rides dealer NotE derail LaCeS drIed
noel dire Disk mace Rob dries
#
beloni@hopcroft:~/programming/judge/ananagram_156_0$ ./ananagram < ananagram.in2
C
Disk
Hi
NotE
REpLy
derail
drIed
eye
ladder
soon
beloni@hopcroft:~/programming/judge/ananagram_156_0$
hop it helps

Getting RE plz Help

Posted: Mon Jan 07, 2008 7:57 pm
by ata
hi ...
i m getting RE for this program....
cant find out why..
Can anyone help plz...

here is my code.........

Code: Select all


#include<stdio.h>
#include<string.h>
int str[26];
char result[1001][25];

int is_ana(char c[],char d[])
{
	char e[25],b[25];
	int i,j,k;

	strcpy(e,c);
	strcpy(b,d);
	if(strlen(e)!=strlen(b))
	return 0;
	
	for(i=0;i<26;i++)
		str[i]=0;
	
	for(k=0;k<strlen(e);k++)
	{
		if(e[k]>='A' && e[k]<='Z')
			e[k]='a'+e[k]-'A';
	}
	
	for(k=0;k<strlen(b);k++)
	{
		if(b[k]>='A' && b[k]<='Z')
			b[k]='a'+b[k]-'A';
	}

	for(j=0;j<strlen(e);j++)
	{
		i=e[j]-'a';
		str[i]=str[i]+1;
	}
	
	for(j=0;j<strlen(b);j++)
	{
		i=b[j]-'a';
		str[i]=str[i]-1;
	}
	i=0;
	while(i<26)
	{
		if(str[i]==0)
			i++;
		else
			return 0;
	}
	return 1;

}

int main()
{
	char a[1001][25];
	char temp[25];
	int i,j,l,flag,x;
	i=0;
	while(scanf("%s",temp)==1)
	{
		if(strcmp(temp,"#")==0)
			break;
	
		strcpy(a[i],temp);
			i++;
	}
	x=0;
	for(j=0;j<i;j++)
	{
		if(strcmp(a[j],"0")==0)
			continue;
		flag=0;
	
		for(l=0;l<i;l++)
		{
		
			if(j==l || (!strcmp(a[j],"0")))
				continue;
			if(is_ana(a[j],a[l])==1)
			{
				strcpy(a[l],"0");
				flag=1;
				
			}
		}
		
		if(flag==0)
		{
			strcpy(result[x],a[j]);
			x++;
		}
			
	}

	for(i=0;i<x-1;i++)
		for(j=i+1;j<x;j++)
		{
			if(strcmp(result[i],result[j])>0)
			{
				strcpy(temp,result[j]);
				strcpy(result[j],result[i]);
				strcpy(result[i],temp);
			}
		}

	for(i=0;i<x;i++)
		printf("%s\n",result[i]);
	return 0;
}
plz help

156 Ananagram WA? WHY?

Posted: Fri Oct 05, 2012 12:18 am
by Burhanuddin
DELETED!

Re: 156 Ananagram WA? WHY?

Posted: Fri Oct 05, 2012 8:08 pm
by brianfry713
Print a newline at the end of the last line. You'll still get WA after fixing that. Try reading a string at a time instead of a char at a time. When I test your code on my system I get a newline at the start of the output for the input:

Code: Select all

a
#

Re: 156 Ananagram WA? WHY?

Posted: Fri Oct 05, 2012 10:27 pm
by Burhanuddin
Actually I was printing a new line after the output, but then I thought that was the problem.
Anyways you are correct, the problem was that it was printing a new line at the beginning of the output for some inputs. I corrected that by checking the size of the char vector. So now its AC!
Thanks for that input!

Re: 156 Ananagram WA? WHY?

Posted: Fri Sep 20, 2013 3:39 pm
by IanSwartz
Hi, getting RTE, possibly due to erasing elements in the vector and iterating through it at the same time,
but it runs fine on my pc so I can't find the error. All advice and criticism appreciated, thx.

Code: Select all

removed
Got AC, thanks, funny thing is the compiler pointed that out but I usually ignore the compiler warnings.

Re: 156 Ananagram WA? WHY?

Posted: Fri Sep 20, 2013 11:37 pm
by brianfry713
Change this function to:

Code: Select all

bool myVSort(string lhs, string rhs)
{
    return (lhs<rhs);
}