726 - Decode

All about problems in Volume 7. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Keyer
New poster
Posts: 1
Joined: Sat Jul 12, 2003 1:09 pm
Location: China
Contact:

726 - Decode

Post 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!

Red Scorpion
Experienced poster
Posts: 192
Joined: Sat Nov 30, 2002 5:14 am

Post 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. :lol: :lol:

Red Scorpion
Experienced poster
Posts: 192
Joined: Sat Nov 30, 2002 5:14 am

Post by Red Scorpion »

Hi, nobody helpp.. :x :x

kostik
New poster
Posts: 2
Joined: Fri May 14, 2004 8:48 am

726 Decode

Post by kostik »

need code on pascal or C

titid_gede
Experienced poster
Posts: 187
Joined: Wed Dec 11, 2002 2:03 pm
Location: Mount Papandayan, Garut

Post by titid_gede »

what for? your assignment? isn't that a bad idea since you cheat yourself?
Kalo mau kaya, buat apa sekolah?

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

The input file can be very big. Try allowing ~40000 lines! :wink:
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

dpitts
New poster
Posts: 31
Joined: Tue Jun 17, 2003 10:10 pm

Post 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]

Guest
New poster
Posts: 39
Joined: Wed May 19, 2004 5:52 pm
Location: Dhaka, Bangladesh
Contact:

Post 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:

Code: Select all

 Removed 
Any help is really appreciated. :cry:
Last edited by on Thu Sep 02, 2004 5:03 pm, edited 2 times in total.

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post 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!!
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

Guest
New poster
Posts: 39
Joined: Wed May 19, 2004 5:52 pm
Location: Dhaka, Bangladesh
Contact:

Post 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.

Andrew Neitsch
New poster
Posts: 43
Joined: Fri Jun 25, 2004 9:37 pm

Post 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.

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

[quote="
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post 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 :roll:

Ciao!!!

Claudio

User avatar
Riyad
Experienced poster
Posts: 131
Joined: Thu Aug 14, 2003 10:23 pm
Location: BUET
Contact:

some one give me some I/O

Post 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
HOLD ME NOW ,, I AM 6 FEET FROM THE EDGE AND I AM THINKIN.. MAY BE SIX FEET IS SO FAR DOWN

Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal »

The memory limit is 32MB. So one can also get Accepted by using a linear array not exceeding 32MB.

Post Reply

Return to “Volume 7 (700-799)”