Page 2 of 3
Re: More case tests
Posted: Fri Aug 11, 2006 11:05 am
by surya ss
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 ?
Re: More case tests
Posted: Fri Aug 11, 2006 3:14 pm
by cytmike
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.
Re: More case tests
Posted: Fri Aug 11, 2006 4:15 pm
by Martin Macko
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:
Re: More case tests
Posted: Sat Aug 12, 2006 3:32 am
by surya ss
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:
well thank you, I don't think there will be a '^' in the input
Re: More case tests
Posted: Sat Aug 12, 2006 7:39 pm
by Martin Macko
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:
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...
Re: More case tests
Posted: Tue Aug 15, 2006 2:32 am
by surya ss
Martin Macko wrote:surya ss wrote:Martin Macko wrote:
Your code isn't working for:
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
Re: More case tests
Posted: Tue Aug 15, 2006 10:55 am
by Martin Macko
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.
Posted: Wed Oct 11, 2006 4:40 am
by mrahman
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;
}
WA WA WA plz help
Posted: Wed Nov 15, 2006 4:05 am
by khaled_cs
I am getting correct output for every input in this thread, but still WA. Please help me. Here is my code
wa
Posted: Wed Sep 05, 2007 6:30 pm
by dipaly
im getting wa ....

help me plz ..
here is my code
thanx in adv..
Posted: Wed Sep 05, 2007 8:59 pm
by Jan
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.
Re: wa
Posted: Thu Sep 06, 2007 10:12 am
by dipaly
thanx ...

.. i do as u said & ac now
Re:
Posted: Wed Jul 30, 2008 11:42 am
by Robert Gerbicz
Martin Macko wrote:
Try this one:
My output is as follows:
That's wrong, my AC gives:
I've assumed that the maximum length of a word is less than 64.
Re: 11062 - Andy's Second Dictionary
Posted: Tue Dec 23, 2008 6:34 pm
by mukit
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.
Re: 11062 - Andy's Second Dictionary
Posted: Thu Dec 25, 2008 3:17 pm
by mukit
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.