726 - Decode

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

Moderator: Board moderators

726 - Decode

Postby Keyer » Sun Jul 13, 2003 1:20 pm

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!
Keyer
New poster
 
Posts: 1
Joined: Sat Jul 12, 2003 1:09 pm
Location: China

Postby Red Scorpion » Thu Oct 23, 2003 7:13 am

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

Postby Red Scorpion » Mon Jan 05, 2004 2:04 pm

Hi, nobody helpp.. :x :x
Red Scorpion
Experienced poster
 
Posts: 192
Joined: Sat Nov 30, 2002 5:14 am

726 Decode

Postby kostik » Tue May 18, 2004 1:01 pm

need code on pascal or C
kostik
New poster
 
Posts: 2
Joined: Fri May 14, 2004 8:48 am

Postby titid_gede » Tue May 18, 2004 5:13 pm

what for? your assignment? isn't that a bad idea since you cheat yourself?
Kalo mau kaya, buat apa sekolah?
titid_gede
Experienced poster
 
Posts: 187
Joined: Wed Dec 11, 2002 2:03 pm
Location: Mount Papandayan, Garut

Postby Observer » Tue Aug 03, 2004 7:02 am

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
Observer
Guru
 
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Postby dpitts » Fri Aug 27, 2004 11:21 pm

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]
dpitts
New poster
 
Posts: 31
Joined: Tue Jun 17, 2003 10:10 pm

Postby Guest » Mon Aug 30, 2004 2:51 pm

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.
Guest
New poster
 
Posts: 39
Joined: Wed May 19, 2004 5:52 pm
Location: Dhaka, Bangladesh

Postby Observer » Mon Aug 30, 2004 4:07 pm

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
Observer
Guru
 
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Postby Guest » Tue Aug 31, 2004 5:31 pm

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.
Guest
New poster
 
Posts: 39
Joined: Wed May 19, 2004 5:52 pm
Location: Dhaka, Bangladesh

Postby Andrew Neitsch » Wed Sep 01, 2004 7:00 pm

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.
Andrew Neitsch
New poster
 
Posts: 43
Joined: Fri Jun 25, 2004 9:37 pm

Postby Observer » Wed Sep 01, 2004 8:13 pm

[quote="
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Observer
Guru
 
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Postby CDiMa » Thu Sep 02, 2004 10:04 am

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
CDiMa
Experienced poster
 
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

some one give me some I/O

Postby Riyad » Sun Jan 30, 2005 6:29 pm

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
User avatar
Riyad
Experienced poster
 
Posts: 131
Joined: Thu Aug 14, 2003 10:23 pm
Location: BUET

Postby Raiyan Kamal » Tue Mar 29, 2005 4:41 pm

The memory limit is 32MB. So one can also get Accepted by using a linear array not exceeding 32MB.
Raiyan Kamal
Experienced poster
 
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh

Next

Return to Volume VII

Who is online

Users browsing this forum: No registered users and 0 guests