11062 - Andy's Second Dictionary

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

Moderator: Board moderators

surya ss
New poster
Posts: 22
Joined: Sat Jun 11, 2005 7:31 pm

Re: More case tests

Post by surya ss » Fri Aug 11, 2006 11:05 am

Martin Macko wrote:
willima wrote:Here are more 1 case test:
In addition to your output my AC wrote two words more:
-peer
a
adventures
ambitious
and
andy
at
blondes
br
came
com
disney-land
disneyland
dream-theater-scenes
fork
getting
going
guy
have
home
i
in
inside
is
left
little-guy
long
me
mind
moment
now
old
peer-
pop
read
road
sign
so
subconcious
takin
tes-
that
the
they
this
to
two
went
were
what
when
why
will-lima
year
years
The word "-peer" is there from:
...
pe-
er-2-peer!!
...
and the word "tes-" is there from:
...
tes-
-1
I have the same answer but still WA, can someone please check what's wrong with my code ?

Code: Select all

remove after accepted
Last edited by surya ss on Sat Aug 12, 2006 3:33 am, edited 1 time in total.

User avatar
cytmike
Learning poster
Posts: 95
Joined: Mon Apr 26, 2004 1:23 pm
Location: Hong Kong and United States
Contact:

Re: More case tests

Post by cytmike » Fri Aug 11, 2006 3:14 pm

Martin Macko wrote:
willima wrote:Here are more 1 case test:
The word "-peer" is there from:
...
pe-
er-2-peer!!
...
and the word "tes-" is there from:
...
tes-
-1
My AC program gives the same answer as Martin.
By the way, my program gets WA because I read the words one by one instead of the whole line. When I rewrite the program and read the whole line by getline(cin,string_variable) then I get AC.
Impossible is Nothing.

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: More case tests

Post by Martin Macko » Fri Aug 11, 2006 4:15 pm

surya ss wrote:I have the same answer but still WA, can someone please check what's wrong with my code ?
Your code isn't working for:

Code: Select all

abc^def ghi

surya ss
New poster
Posts: 22
Joined: Sat Jun 11, 2005 7:31 pm

Re: More case tests

Post by surya ss » Sat Aug 12, 2006 3:32 am

Martin Macko wrote:
surya ss wrote:I have the same answer but still WA, can someone please check what's wrong with my code ?
Your code isn't working for:

Code: Select all

abc^def ghi
well thank you, I don't think there will be a '^' in the input

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: More case tests

Post by Martin Macko » Sat Aug 12, 2006 7:39 pm

surya ss wrote:
Martin Macko wrote:
surya ss wrote:I have the same answer but still WA, can someone please check what's wrong with my code ?
Your code isn't working for:

Code: Select all

abc^def ghi
well thank you, I don't think there will be a '^' in the input
Maybe. But your code didn't work for a whole family of such similar symbols... the symbol '^' was just an example of one such symbol...

surya ss
New poster
Posts: 22
Joined: Sat Jun 11, 2005 7:31 pm

Re: More case tests

Post by surya ss » Tue Aug 15, 2006 2:32 am

Martin Macko wrote:
surya ss wrote:
Martin Macko wrote: Your code isn't working for:

Code: Select all

abc^def ghi
well thank you, I don't think there will be a '^' in the input
Maybe. But your code didn't work for a whole family of such similar symbols... the symbol '^' was just an example of one such symbol...
my bad, I was think that there's only character 'A-Za-z0-9!' and '-' in the input

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: More case tests

Post by Martin Macko » Tue Aug 15, 2006 10:55 am

surya ss wrote:my bad, I was think that there's only character 'A-Za-z0-9!' and '-' in the input
Very bad assumption, as there are symbols such as '.', ':' and '"' already in the sample input of the problem statement.

mrahman
New poster
Posts: 25
Joined: Mon Oct 24, 2005 9:45 am
Location: Bangladesh
Contact:

Post by mrahman » Wed Oct 11, 2006 4:40 am

I am getting Runtime Error at least 12 times and have no clue. Plz help me

Code: Select all

#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
char list[510][10001],cnt;
char str[100001],temp[10001];
int sort_function(const void *a, const void *b)
{
	return (strcmp((char *)a,(char *)b));
}
int main(void)
{
	int i,j,wne,k;
	
	cnt=wne = 0;
	//freopen("C:\\11062.txt","r",stdin);
	while(gets(str)!=NULL)
	{
		i=0;
		
		while(str[i])
		{
			//if(wne==0)
			j=0;
			
			while(isalpha(str[i])||str[i]=='-')
			{
				temp[j++]=str[i++];
				
			}
			if(!str[i])
			{
				if(j&&temp[j-1]=='-'){j--;wne=1;}
				else wne = 0;
			}
			else wne = 0;
			if(wne==0)
			{
				temp[j]=0;
				for(k=0;k<j;k++)
				{
					list[cnt][k]=tolower(temp[k]);					
				}
				list[cnt][k]=0;
				cnt++;
			}
			if(!str[i])break;

			while(str[i]&& !(isalpha(str[i])||str[i]=='-'))i++;

		}
		
	}
	qsort((void *)list,cnt,sizeof(list[0]),sort_function);
	printf("%s\n",list[0]);
	for(i=1;i<cnt;i++)
	{
		if(strcmp(list[i],list[i-1]))	
		printf("%s\n",list[i]);

	}
	return 0;
}
Practice Makes a man perfect

khaled_cs
New poster
Posts: 2
Joined: Sun Jan 15, 2006 4:29 am

WA WA WA plz help

Post by khaled_cs » Wed Nov 15, 2006 4:05 am

I am getting correct output for every input in this thread, but still WA. Please help me. Here is my code

Code: Select all

AC

dipaly
New poster
Posts: 20
Joined: Tue Sep 19, 2006 6:18 pm
Location: bangladesh
Contact:

wa

Post by dipaly » Wed Sep 05, 2007 6:30 pm

im getting wa .... :evil: help me plz ..
here is my code

Code: Select all

ac
thanx in adv..
Last edited by dipaly on Thu Sep 06, 2007 10:12 am, edited 1 time in total.
everything is so hard to me

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Wed Sep 05, 2007 8:59 pm

Try the set below..

Input:

Code: Select all

a-
a-
a-
a-
a
a-a
a
a-a-a-
a
a-a-aa
a-a-aa-a
a aa aaa aaaa aaaaa 8271637676876^^@&*^&@ @^*&^ bb@bbb
Output:

Code: Select all

a
a-a
a-a-aa
a-a-aa-a
aa
aaa
aaaa
aaaaa
bb
bbb
And some important things..
1. When the array is big, its better to use it as global.
2. Some comparisons should be used carefully..

Code: Select all

if((strcmp(res[j],res[j-1])!=0) && j>0)
if j is zero, then your code first compares res[0] and res[-1] (negative index). So, you should use

Code: Select all

if(j>0 && (strcmp(res[j],res[j-1])!=0))
Hope these help.
Ami ekhono shopno dekhi...
HomePage

dipaly
New poster
Posts: 20
Joined: Tue Sep 19, 2006 6:18 pm
Location: bangladesh
Contact:

Re: wa

Post by dipaly » Thu Sep 06, 2007 10:12 am

thanx ... :D .. i do as u said & ac now
everything is so hard to me

Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Re:

Post by Robert Gerbicz » Wed Jul 30, 2008 11:42 am

Martin Macko wrote: Try this one:

Code: Select all

A-
--
-

B--
--

C--
 --
--
My output is as follows:

Code: Select all

--
a-
b--
c-
That's wrong, my AC gives:

Code: Select all

a-
b--
c---
I've assumed that the maximum length of a word is less than 64.

mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh
Contact:

Re: 11062 - Andy's Second Dictionary

Post by mukit » Tue Dec 23, 2008 6:34 pm

Hi, I'm getting WA in this problem. Please give some I/O ...

Code: Select all

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

#define _null	'\0'

char word[505][10011];
char data[505][10011];
char buf[99999];

int sort_func(const void *a,const void *b)
{
	return (strcmp((char*)a,(char*)b));
}

int main()
{
	
	int len,ct,vt;
	bool mark = false;
	bool enter = false;
	char delims[] = ",':;?<>/0123456789~!@#$%^&*()+|\\.\"";
	ct = vt = 0;
	
	memset(word,_null,sizeof(word));
	memset(data,_null,sizeof(data));
	
	while(scanf("%s",buf)==1)
	{
		len = strlen(buf);
		
		for(int i = 0;i < len;i++)
		{
			if(isalpha(buf[i]))
			{
				if(isupper(buf[i]))
				{
					buf[i] = (buf[i] + 32);
				}
			}
		}
		
		if(mark == true)
		{
			if(buf[len-1]!='-')
			{
				strcat(word[ct],buf);
				mark = false;
				ct++;
				continue;
			}
		}
		if(buf[len-1]=='-' && len > 0)
		{
			if(len == 1)
			{
				strcat(word[ct],"-");
				mark = false;
				ct++;
				continue;
			}
			strncat(word[ct],buf,len-1);
			mark = true;
			continue;
		}
		strcat(word[ct],buf);
		ct++;
	}
	//////////////////////
	char *result=NULL;
	for(int i = 0;i < ct;i++)
	{
		result = strtok(word[i],delims);
		while(result!=NULL)
		{
			strcpy(data[vt],result);
			result = strtok(NULL,delims);
			vt++;
		}
	}
	//////////////////////
	qsort((void*)data,vt,sizeof(data[0]),sort_func);
	//////////////////////
	printf("%s\n",data[0]);
	strcpy(buf,data[0]);
	for(int i = 1;i < vt;i++)
	{
		if(strcmp(buf,data[i]))
		{
			if(data[i][0]!=_null)
			{
				printf("%s\n",data[i]);
				strcpy(buf,data[i]);
			}
		}
	}
	//////////////////////
	//for(int i = 0;i < ct;i++)
	//	  printf("%s\n",word[i]);
	return 0;
}

Thank's in advance.

mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh
Contact:

Re: 11062 - Andy's Second Dictionary

Post by mukit » Thu Dec 25, 2008 3:17 pm

Ok, forget my previous post. I got it AC using STL (set).
One line is important.
The hyphen character is part of the word if, and only if, not followed by a newline.
And it seems the input data is weak.

Post Reply

Return to “Volume 110 (11000-11099)”