Page 2 of 2

Well...

Posted: Sat Sep 04, 2004 1:51 am
by _.B._
I found only 2 differences between the I/Os I've tried.
They are:

1. You'll have to "trim" blank spaces at the beginning and/or the end of every word. I made this one in Pascal, and I only read valid chars to build the words.
I believe the input MAY have words with blank spaces at the beginning or end of words.

2. Your code prints an extra blank line at the end of the output. That should only represent a P.E., not a W.A.
Just use a bool Flag = false; or a counter, like:
[cpp] n=atoi(word2.original);
if (Flg)
cout << endl;
Flg = true;[/cpp]

That's all my C++ knoledge can do for you rigth now :wink:
Hope that helps.

Posted: Sat Sep 04, 2004 2:19 am
by wolf
I did what you said, but still WA. Notwithstanding, thanx for checking my program :-D Maybe I will try to do this in Pascal in the future, like you, but I haven't used this language since last year !!! This could be a challange :-)

Maybe this.

Posted: Sat Sep 04, 2004 7:14 pm
by _.B._
Heya Wolf!
It's a pity I couldn't be of more help.
Well, since we are gussing the input for this problem due to the lack of description, LAST thing I can think of is that the input looks like this (since others look like this too):

Code: Select all

3

8
lato
atol
microphotographics
rata
rola
tara
tola
pies
tola
kola
aatr
photomicrographics
END

5
xxx
loka
kola
kola
loka
kola
photomicrographics
xxx
END

0
abcde
fgh
microphotographics
END
Output:

Code: Select all

Anagrams for: tola
  1) lato
  2) atol
  3) tola
Anagrams for: kola
No anagrams for: kola
Anagrams for: aatr
  1) rata
  2) tara
Anagrams for: photomicrographics
  1) microphotographics

Anagrams for: kola
  1) loka
  2) kola
  3) kola
  4) loka
Anagrams for: photomicrographics
No anagrams for: photomicrographics
Anagrams for: xxx
  1) xxx

Anagrams for: abcde
No anagrams for: abcde
Anagrams for: fgh
No anagrams for: fgh
Anagrams for: microphotographics
No anagrams for: microphotographics

My program gives rigth answer, yours don't.
I don't know, do a
[cpp]while (cin.peek() == '\n')
cin.get();[/cpp]
or something like that.
Good luck!

Keep posting!

Posted: Sat Sep 04, 2004 9:40 pm
by wolf
Finaly I make some changes and ... got AC !!! It's my 50 AC problem now !!! (magic number :-D ). Thank you very much _.B._ The last version of input you posted was absolutely right and (for those who will propably have problems with 630 in the future) the input has NO extra spaces.

It's a pity that the problem description is completly different with right form!

Best regard,
Wolf

P.S. I'll remove my code form above :lol:

Good!

Posted: Sat Sep 04, 2004 11:54 pm
by _.B._
Glad I could help ;)
Gratz on your 50 :)

Keep posting!

Posted: Mon Nov 29, 2004 8:54 pm
by CodeMaker
Hi, :-? can anyone tell me how to escape from P.E. in this problem.
I have tried a lot of things, still P.E. I got 6 P.E. for this problems

here is the things i have tried-

considering multiple cases, i printed one blank line after each case. then i
tried except the last case. i also tried %3d for the srl. no. and also " %d"
and all the combinations of these. and i ensure that my other printf are
ok , i copied then from the problem descripton......

thanks......

Posted: Wed Jan 12, 2005 6:20 am
by _.B._
Greetings!
Did you try the I/O posted above?

630

Posted: Thu Sep 15, 2005 5:17 pm
by Sakib
i dont understand what is wrong.
please help me with some input output.
Here is my code.

Code: Select all

#include<stdio.h>
#include<string.h>
#include<ctype.h>

char ss[21],tt[21];
int i,j,k,n,m,p,q,r;

struct Texts
{
	char word[21];
	int len;
};
Texts text[2000];

//////////////////////////////////////////

void sort(char s[],int p)
{
	int i,j;
	char tmp;
	for(i=1;i<p;i++)
	{
		for(j=0;j<i;j++)
		{
			if(s[i]>s[j])
			{
				tmp=s[i];
				s[i]=s[j];
				s[j]=tmp;
			}
		}
	}
}

int isSame(char s[],int p,char t[],int q)
{
	int i;
	char t1[21],t2[21];
	if(p!=q)return 0;
	for(i=0;i<p;i++){t1[i]=s[i];}
	for(i=0;i<q;i++){t2[i]=t[i];}
	sort(t1,p);
	sort(t2,q);
	for(i=0;i<p;i++)
	{
		if(t1[i]!=t2[i])return 0;
	}
	return 1;
}


//////////////////////////////////////////

void main()
{
/////////////////////////////////
	while(scanf("%d\n",&n)==1)
	{
	for(i=0;i<n;i++)
	{
		scanf("%s",tt);
		r=strlen(tt);
		for(j=0;j<r;j++)
		{
			text[i].word[j]=tt[j];
		}
		text[i].len = r;
	}
//////////////////////////////////

	while(scanf("%s",ss)==1)
	{
		r = strlen(ss);
		if(strcmp(ss,"END")==0)break;
		printf("Anagrams for: ");
		for(j=0;j<r;j++){printf("%c",ss[j]);}
		printf("\n");
		k=0;
		for(i=0;i<n;i++)
		{
			if(isSame(ss,r,text[i].word,text[i].len)==1)
			{
				k++;
				printf("%3d) ",k);
				for(j=0;j<text[i].len;j++)printf("%c",text[i].word[j]);
				printf("\n");
			}
		}
		if(k==0)
		{
			printf("No anagrams for: ");
			for(j=0;j<r;j++){printf("%c",ss[j]);}
			printf("\n");
		}
	}
	//printf("\n");
	}
////////////////////////////////////////////////
}

Posted: Sat Oct 01, 2005 12:47 pm
by A1
See the updated problem statement....
http://acm.uva.es/p/v6/630.html

Posted: Sat Oct 01, 2005 6:06 pm
by Sakib
Thanks a lot!!!!!!!!
I am ACC now. :D

Re: 630 - Anagrams (II)

Posted: Tue Mar 25, 2014 3:29 pm
by uDebug
Replying to follow the thread.