I tried to solve the problem.
Thought it is a simple text processing problem.
But get WA all the time.
Would someone give some input/output? Thx
10584  Text Formalization
Moderator: Board moderators

 Experienced poster
 Posts: 128
 Joined: Fri Nov 15, 2002 7:45 am
 Location: Kyrgyzstan
Hello!
I've recently solved the problem and I also got WA the first time. I think there are two possible mistakes:
1. Suppose, you have a contraction "AB" > "A and B" and you meet in text string AB. According to the problem statement you should output "A and B"  not "A AND B". Note, that if the contraction were "Ab" > "A and B" than you would print "A AND B", however.
2. If you have two contractions "AB C">"A B and C" and "AB">"A and B" and analize string AB C D ... you shouldn't stop when you found match AB  you are to continue comparing because you will meet AB C which should be replaced as its contraction appear earlier in the input.
Hope this will help you.
Have AC.
Andrey.
I've recently solved the problem and I also got WA the first time. I think there are two possible mistakes:
1. Suppose, you have a contraction "AB" > "A and B" and you meet in text string AB. According to the problem statement you should output "A and B"  not "A AND B". Note, that if the contraction were "Ab" > "A and B" than you would print "A AND B", however.
2. If you have two contractions "AB C">"A B and C" and "AB">"A and B" and analize string AB C D ... you shouldn't stop when you found match AB  you are to continue comparing because you will meet AB C which should be replaced as its contraction appear earlier in the input.
Hope this will help you.
Have AC.
Andrey.
Sorry , I don't understand your meanning clearly.
If I have a contraction "AB" > " A and B"
when I input ab , I should output "a and b"?
AB, I should output "A AND B"?
Ab,, I should output "A and b"?
maybe I misunderstand the problem.
now we have two contractions.
1. "AB C" > "A B and C"
2. "AB" >"A and B"
iwhen I input AB C D, I search from 1 to C.
if some contraction matched , I used the rule?
Am I right?
Thx your reply
According the problem, Each contraction may appear as listed, entirely uppercase, or capitalized (first letter uppercase, remaining letters as listed). The expansion should follow the same rule; if a contraction is uppercased, the expansion should be uppercased as well.Andrey Mokhov wrote: 1. Suppose, you have a contraction "AB" > "A and B" and you meet in text string AB. According to the problem statement you should output "A and B"  not "A AND B". Note, that if the contraction were "Ab" > "A and B" than you would print "A AND B", however.
If I have a contraction "AB" > " A and B"
when I input ab , I should output "a and b"?
AB, I should output "A AND B"?
Ab,, I should output "A and b"?
maybe I misunderstand the problem.
If more than one case applies, choose the earliest matching case in the list: "as listed," "uppercased," and "capitalized."2. If you have two contractions "AB C">"A B and C" and "AB">"A and B" and analize string AB C D ... you shouldn't stop when you found match AB  you are to continue comparing because you will meet AB C which should be replaced as its contraction appear earlier in the input.
Andrey.
now we have two contractions.
1. "AB C" > "A B and C"
2. "AB" >"A and B"
iwhen I input AB C D, I search from 1 to C.
if some contraction matched , I used the rule?
Am I right?
Thx your reply

 Experienced poster
 Posts: 128
 Joined: Fri Nov 15, 2002 7:45 am
 Location: Kyrgyzstan
Hi!
1) ab doesn't match the contraction.
2) AB should be A and B (as listed)  not A AND B (uppercased)
3) Ab doesn't match the contraction either.
And about my second point from my previous topic  I just meant that your program shouldn't stop search as soon as you find some match because there may be longer match beginning with the same prefix.
Yeah... hard to explain in foreign language
But I try
Bye.
Andrey.
The problem is that sometimes you can't say if it is as listed, uppercased or capitalized! Can you say AB is uppercased or as listed if it was AB at start? So as problem statement says in such case you should consider it to be written as listed:windows2k wrote:Each contraction may appear as listed, entirely uppercase, or capitalized (first letter uppercase, remaining letters as listed). The expansion should follow the same rule; if a contraction is uppercased, the expansion should be uppercased as well.
And nowIf more than one case applies, choose the earliest matching case in the list: "as listed," "uppercased," and "capitalized."
No, all three cases are incorrect!windows2k wrote:If I have a contraction "AB" > " A and B"
when I input ab , I should output "a and b"?
AB, I should output "A AND B"?
Ab,, I should output "A and b"?
1) ab doesn't match the contraction.
2) AB should be A and B (as listed)  not A AND B (uppercased)
3) Ab doesn't match the contraction either.
And about my second point from my previous topic  I just meant that your program shouldn't stop search as soon as you find some match because there may be longer match beginning with the same prefix.
Yeah... hard to explain in foreign language
But I try
Bye.
Andrey.

 Guru
 Posts: 1080
 Joined: Thu Dec 19, 2002 7:37 pm
As I learned after getting a few WAs, don't try to be smart!
The input
Transforms to
And not to the more sensible "HELLO! It is obvious that Babbit's European License (EL) is expired."
The input
Code: Select all
2 1
"it's" > "it is"
".." > "."
"EL" > "European License"
HELLO! It's obvious that Babbit's EL is expired......
#
Code: Select all
HEuropean License (EL)LO! It is obvious that Babbit is EL is expired...
#