10815 - Andy's First Dictionary
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10815 - Andy's First Dictionary
Don't print a blank line at the start of the output.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 21
- Joined: Mon Jun 18, 2012 12:52 am
- Location: Dhaka, Bangladesh.
- Contact:
Re: 10815 - Andy's First Dictionary
I got WA. Please help to find my mistake. My idea is:
Thanks in advance.
Update: Accepted. Hint: Considering what we need is importent because we don't know what should appear in text.
- get a line using fgets until EOF
- check Capital letters, make them small letters
- tokenize string using strtok() by " 0123456789!@#$%^&*\()_+=-[]{}|\\:;\"\'<,>./?`~" and insert into a map as key(because it sorts itself)
- finally print the map keys
Code: Select all
code removed
Update: Accepted. Hint: Considering what we need is importent because we don't know what should appear in text.
Re: 10815 - Andy's First Dictionary
Congrats on figuring this out by yourself!PromeNabid wrote:Update: Accepted. Hint: Considering what we need is importent because we don't know what should appear in text.
Re: 10815 - Andy's First Dictionary
What's wrong with my code? I am getting wrong answer.
![:oops:](./images/smilies/icon_redface.gif)
Code: Select all
Code removed after AC
Last edited by Ahmad93 on Sat Jul 26, 2014 1:27 am, edited 1 time in total.
Re: 10815 - Andy's First Dictionary
For this input
Your output
Acc output
Code: Select all
Advanced search
Accepted.
Thanks in advance.
Code: Select all
accepted
advanced
in
search
thanks
Code: Select all
accepted
advance
advanced
in
search
thanks
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 10815 - Andy's First Dictionary
What a foolish of me! That unnecessary 'return 100' in my strcmp is giving me successive wrong answers!
Thanks a lot to you lighted.![:D](./images/smilies/icon_biggrin.gif)
Thanks a lot to you lighted.
![:D](./images/smilies/icon_biggrin.gif)
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 10815 - Andy's First Dictionary
I am getting RTE. Whats wrong with my code?
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
int len, i, j,c=0;
char txt[202], word[5002][202], temp[202];
while(scanf("%s",&txt)!=EOF)
{
len=strlen(txt);
j=0;
for(i=0;i<len;i++)
{
if(txt[i]>='a' && txt[i]<='z')
temp[j++]=txt[i];
else if(txt[i]>='A' && txt[i]<='Z')
temp[j++]=txt[i]-'A'+'a';
}
temp[j]='\0';
if(strlen(temp)>0)
{
strcpy(word[c], temp);
c++;
}
}
for(i=0;i<c;i++)
{
for(j=0;j<c-1;j++)
{
if(strcmp(word[j], word[j+1])>0)
{
strcpy(temp, word[j]);
strcpy(word[j], word[j+1]);
strcpy(word[j+1], temp);
}
}
}
for(i=0;i<c;i++)
puts(word[i]);
return 0;
}
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10815 - Andy's First Dictionary
Try running your code on the sample input.
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 10815 - Andy's First Dictionary
My code works fine for the given sample input in problem.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Re: 10815 - Andy's First Dictionary
Your code prints repeated words. http://ideone.com/N1wbfo
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 10815 - Andy's First Dictionary
Input file will contain up to 5000 lines, not 5000 words. Words are repeated and number of distinct words <= 5000. So you get RE. I used array for 30000 words.The input file is a text with no more than 5000 lines... You can be sure that he number of distinct words in the text does not exceed 5000
![:)](./images/smilies/icon_smile.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 10815 - Andy's First Dictionary
what will be the maximum size of a distinct word?
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com