Hi all.....
Could some one plz help me in this problem, like some useful hints in solving this problem
just to get me started
thanx in advance
508 - Morse Mismatches
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 508 Morse Mismatches
I first map each character to it's string encoding in the Morse code table.
Then I encode each word in the context section one letter at a time to build a Morse code string. If that Morse code word is unique, I store it in another map. If it is not unique, I add a "!" to the end of the existing word in that map if it doesn't already have one.
For each Morse word I search for it in the map. If it can't be found I search for the closest match and append a "?".
My code is straightforward.
Then I encode each word in the context section one letter at a time to build a Morse code string. If that Morse code word is unique, I store it in another map. If it is not unique, I add a "!" to the end of the existing word in that map if it doesn't already have one.
For each Morse word I search for it in the map. If it can't be found I search for the closest match and append a "?".
My code is straightforward.
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 139
- Joined: Wed May 18, 2011 3:04 pm
Re: 508 - Morse Mismatches
The description of problem needs fix.
It said that:
"If multiple context words match morse perfectly, then select the matching word with the fewest characters.
If this still results in an ambiguous match, any of these matches may be displayed. If multiple context
words exist for a given morse, the first matching word will be displayed followed by an exclamation
point (‘!’)."
Indeed, the judge only accept answer base one the latter rule, If you print the matching word with fewest characters, you will get WA.
It said that:
"If multiple context words match morse perfectly, then select the matching word with the fewest characters.
If this still results in an ambiguous match, any of these matches may be displayed. If multiple context
words exist for a given morse, the first matching word will be displayed followed by an exclamation
point (‘!’)."
Indeed, the judge only accept answer base one the latter rule, If you print the matching word with fewest characters, you will get WA.
metaphysis: http://uhunt.onlinejudge.org/id/95895
My solutions for UVa problems: https://github.com/metaphysis/Code.
My solutions for UVa problems: https://github.com/metaphysis/Code.
-
- New poster
- Posts: 33
- Joined: Tue Apr 27, 2004 7:41 pm
- Location: Santa Clara / Mountain View, CA, USA
- Contact:
Re: 508 - Morse Mismatches
Indeed, that's what I got for the sample input, but my output is different from the sample output:
Code: Select all
WHAT
HATH
GOD
WROTH?
WHAT
AN
EARTHQUAKE
IM!
READY
TO
IM!
I Believe I Can - leestime.com