726 - Decode
Moderator: Board moderators
726 - Decode
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!
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!
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
-
- Experienced poster
- Posts: 187
- Joined: Wed Dec 11, 2002 2:03 pm
- Location: Mount Papandayan, Garut
The input file can be very big. Try allowing ~40000 lines! 

7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
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:
output:
Simple mistake to make, and maybe easy to fix? I did, and got AC.[/code]
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.
Code: Select all
The car is blue. The car
is blue. The car is BluE.
The car is bLUe.
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. 
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:
Code: Select all
Removed

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!!
Anyway, the ENCODED message is very long. To handle this, I used an array of string of size 40000! Try it!!
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
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.
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.
-
- New poster
- Posts: 43
- Joined: Fri Jun 25, 2004 9:37 pm
[quote="
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
some one give me some I/O
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 : -
is my approach wrong ???
i assumed the input to be some thing like this :
Regards
Code: Select all
while(gets( known ) ){
if(known[0]==0)break ;
...........
...........
}
i = 0 ;
while(gets( temp )){
strcpy(encoded[i++] , temp);
..........................
....................
}
give output .....
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
HOLD ME NOW ,, I AM 6 FEET FROM THE EDGE AND I AM THINKIN.. MAY BE SIX FEET IS SO FAR DOWN
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact: