Page 1 of 3
726 - Decode
Posted: Sun Jul 13, 2003 1:20 pm
by Keyer
That's the DECODE problem.
I don't know what I have to do.
The problem said "The input file contains two messages separated by a blank line. We will refer to them as `KNOWN' and `ENCODED' messages. This file contains an encoded message.
You are to write a program that decodes the message in the file according to the following guidelines. "
And the Sample Input and Output:
Sample Input
The car is blue.
Wkh fdu lv eoxh.
Sample Output
The car is blue.
"The car is blue." is 'KNOWN', "Wkh fdu lv eoxh." is 'ENCOEDED',
what shall we do?just output "The car is blue."???
I just do not quite understand the meaning of this problem.
CAN YOU HELP ME,THANKS A LOT!
Posted: Thu Oct 23, 2003 7:13 am
by Red Scorpion
Hi, everyone.
I have the same problem as you, keyer.
I got many WA, I just simulate what they want.
Is the input just have 3 lines.
#lines1 = known messages.
#lines2 = blank line.
#lines3 = encoded messages.
Or the input have more than 3 ?
Please help.

Posted: Mon Jan 05, 2004 2:04 pm
by Red Scorpion
Hi, nobody helpp..

726 Decode
Posted: Tue May 18, 2004 1:01 pm
by kostik
need code on pascal or C
Posted: Tue May 18, 2004 5:13 pm
by titid_gede
what for? your assignment? isn't that a bad idea since you cheat yourself?
Posted: Tue Aug 03, 2004 7:02 am
by Observer
The input file can be very big. Try allowing ~40000 lines!

Posted: Fri Aug 27, 2004 11:21 pm
by dpitts
Read carefully. I missed this the first time too.
The input has a known message, and an encoded message, seperated by a blank line...
It never says that the messages are only one line long though..
Input:
Code: Select all
The car is blue. The car
is blue. The car is BLUE.
Wkh fdu lv eoxh. Wkh fdu
lv eoxh. Wkh fdu lv EoxH.
Wkh fdu lv eOXh.
output:
Code: Select all
The car is blue. The car
is blue. The car is BluE.
The car is bLUe.
Simple mistake to make, and maybe easy to fix? I did, and got AC.[/code]
Posted: Mon Aug 30, 2004 2:51 pm
by Guest
Hi dpitts,
My code gives correct answer for your input, still I'm getting RTE. Is it because of the length of KNOWN and ENCODED, or does the problem lie within my comparison function for qsort?
Here's my code:
Any help is really appreciated.

Posted: Mon Aug 30, 2004 4:07 pm
by Observer
I've written something here for this problem before, but somehow it's lost...
Anyway, the ENCODED message is very long. To handle this, I used an array of string of size 40000! Try it!!
Posted: Tue Aug 31, 2004 5:31 pm
by Guest
Hi,
Could you explain a little more about your input routines for KNOWN & ENCODED? I can't understand what you meant by "array of string of size 40000". Is is a single array of chars of length 40000?
Do the messages come as single lines, separated by a blank line? But problem statement says that there can be other blank lines which must appear as received. And also, are there more than one case?
For KNOWN, I'm reading lines using gets() in a array of size 10000, until I get a blank line. Then I'm reading ENCODED, line by line using gets() in a 2D char array capable of taking 5000 lines, each of length 4999.
Thank you.
Posted: Wed Sep 01, 2004 7:00 pm
by Andrew Neitsch
Your integer compare is stupid. If the two numbers are equal, and you add 1 to each, they will still be equal.
Just do return *(int*)a-*(int*)b; to sort in ascending order.
Posted: Wed Sep 01, 2004 8:13 pm
by Observer
[quote="
Posted: Thu Sep 02, 2004 10:04 am
by CDiMa
Andrew Neitsch wrote:Your integer compare is stupid. If the two numbers are equal, and you add 1 to each, they will still be equal.
Just do return *(int*)a-*(int*)b; to sort in ascending order.
Please don't be rude!
I don't know if the code is stupid

, but it doesn't do what you say
Ciao!!!
Claudio
some one give me some I/O
Posted: Sun Jan 30, 2005 6:29 pm
by Riyad
can some one offer me some I / O for the problem 726 . i got WA after my code ran about 0.680 sec . i have considered that both encoded and known text can be in several lines .. more over my programs give correct output for the input given by dpitts ... here is my approach for reading input of the problem : -
Code: Select all
while(gets( known ) ){
if(known[0]==0)break ;
...........
...........
}
i = 0 ;
while(gets( temp )){
strcpy(encoded[i++] , temp);
..........................
....................
}
give output .....
is my approach wrong ???
i assumed the input to be some thing like this :
Code: Select all
known
known
known
known
encoded
encoded
encoded
encoded
encoded
encoded
encoded
EOF
Regards
Posted: Tue Mar 29, 2005 4:41 pm
by Raiyan Kamal
The memory limit is 32MB. So one can also get Accepted by using a linear array not exceeding 32MB.