444 - Encoder and Decoder

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

Moderator: Board moderators

thinker
New poster
Posts: 4
Joined: Mon Mar 28, 2005 8:38 pm

i got Runtime error in 444 !!! but why

Post by thinker »

i got Runtime error in 444 !!! but why. my all input out-puts are ok. my code is followings.

#include<stdio.h>
#include<string.h>
#include<ctype.h>
int a[81];
char str1[81];
int size;


void encode()
{
for(int i=0;i<size;i++)
{
a=str1;
if(a>=100)
{
int x,y,z;
x=((a%100)/10);
y=1;//a/100;
z=((a%100)%10);
a=z*100+x*10+y;
}

else
a=((a%10)*10+((a)/10));
}

for(int h=(size-1);h>=0;h--)
{
printf("%d",a[h]);

}

printf("\n");
}





void decode()
{
int b[20000];
char c[20000];
int k=0;

for(int i=0;i<size;i++)
{
b[k]=str1[i]-48;
k=k+1;
}

int j=0;
for(int d=size-1;d>0;)
{
if(b[d]==1)
{
c[j]=(char)((b[d]*100)+(b[d-1]*10)+b[d-2]);
d=d-3;
j=j+1;
}
else
{
c[j]=(char)((b[d]*10)+b[d-1]);
d=d-2;
j=j+1;
}
}


for(int l=0;l<j;l++)
{
printf("%c",c[l]);
}

printf("\n");

}






void main()
{
//freopen("input.in","r",stdin);
while(gets(str1)!=NULL)
{
size=strlen(str1);

/*int i=0;

if(str1[i]>='0'&&str1[i]<='9')
decode();*/
if(isdigit(str1[0]))
decode();
else
encode();
}
}
Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal »

Dear thinker,
there are some good posts on this topic in this forum. You can see them. Here are also some sample input for you to try with your code.

INPUT:
This is a problem from volume four.
One is to write an encoder-decoder program here.
IS THIS A VALID LINE ?
To B or not TO be is the QUESTION.
to B or NOT to B is tautology !
!!!!!!!!!..........?????????

the quick brown fox jumped over the lazy dog :p

79

i must do what i must do !
332311100123611511711901235012361179401911231110012361151171190123501
Try all the silly cases you can think of
this IS a SILLY case :p
21185231015117999239867673738237923383723511501401611
OUTPUT:
64411711111201231019017118011118112390111141120123901101801891114112112379235115012351150140148
6410141110140123901794113011114112112341110100111199101001544111010011119901110123011792310161150141191123111611235115012310101197
36239687376723863767566823562338372748233837
64879737483896581823101401611235115012310189239748236111110112341111123662311148
332312130111180111161171179611235115012366231116112348978723411111236623111611
36363636363636363664646464646464646464333333333333333333

21185233011110012312122179801231014016112341110181111123001101211901711601230211112012301191111141189237019950171131123101401611

a

332311100123611511711901235012361179401911231110012361151171190123501
i must do what i must do !
2011112370101150140161123011799923711111121235111015117999231218018015015112310140161123801801792312141148
21185231015117999239867673738237923383723511501401611
this IS a SILLY case :p
One last thing, uploading your code is not a good idea. Please try to avoid doing this.
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

What is the input of UFP2161 on the third line
counted from bottom up ?


Is the second symbol one space OR are there 2 spaces.

Judging from his/her output he/she has 2 spaces in the input.

I mean he/she prints twice the number 23 which is
the reverted 32, which represents SPACE in the
input ( in the not encoded message ).

So is it :

s<SPACE>..EG!XLDm,H!bk

or

s<SPACE><SPACE>..EG!XLDm,H!bk



There're other cases in his/her input/output where he/she
prints 2 times 23 instead of one time ? Does the same
apply for them too ? I mean are these two 23s result of
two spaces or ... ?


If the answer is 2 spaces then I can say I cover all test
cases found in the THREADs related to problem.

Can someone give some more ( tricky if possible ) test data ?
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Can someone post some sample I/O different that the I/Os
which are already posted in the topics dedicated to
problem 444.

Are there some special tricky cases ?!
Like test cases with empty lines and so on ?!
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Can someone post some sample I/O different that the I/Os
which are already posted in the topics dedicated to
problem 444.

Are there some special tricky cases ?!
Like test cases with empty lines and so on ?!

For instance my program covers the I/O posted
above by Raiyan Kamal.

Thank you in advance !
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Can someone post some sample I/O different that the I/Os
which are already posted in the topics dedicated to
problem 444.

Are there some special tricky cases ?!
Like test cases with empty lines and so on ?!

For instance my program covers the I/O posted
by Raiyan Kamal in the following thread:
http://online-judge.uva.es/board/viewtopic.php?t=7844

Thank you in advance !
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Stupid BUG as always in an easy problem...
Got ACC now.

Thank you anyway.
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Stupid BUG as always in an easy problem...
Got ACC now.

Thank you anyway.
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Stupid BUG as always in an easy problem...
Got ACC now.

Thank you anyway.
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz »

I've got WA too

here's my code
any suggestions??

Code: Select all

as you wish  
Last edited by jaracz on Wed Jul 20, 2005 5:34 pm, edited 2 times in total.
keep it real!
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Here is some test data for you:


INPUT

Code: Select all

abcdef!,.:;?
abcdef!,.:;?ABCDZYV
369585644433201101001998979
68980986766656369585644433201101001998979
a   bcdef!,.:;?ABCDZY   V
68232323980986766656369585644433201101001998923232379
zyxwvnPQST abracadarbra
79411894117900179997941189792348381808011811911021121221
abczzzzzzYYYYYYY    def!,.:;?ABCDZYV
689809867666563695856444332011010012323232398989898989898221221221221221221998979

OUTPUT

Code: Select all

369585644433201101001998979
68980986766656369585644433201101001998979
abcdef!,.:;?
abcdef!,.:;?ABCDZYV
68232323980986766656369585644433201101001998923232379
a   bcdef!,.:;?ABCDZY   V
79411894117900179997941189792348381808011811911021121221
zyxwvnPQST abracadarbra
689809867666563695856444332011010012323232398989898989898221221221221221221998979
abczzzzzzYYYYYYY    def!,.:;?ABCDZYV

Check if you get the same answers.

Btw, it is a bad habit to post directly your code and
just say "I got WA" :) Try to post code after all other methods
for finding help have failed or if someone asks you to post your code.
That's just my personal opinion.
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Jaracz,

Nice sense of humour from you :) !

Well, do you pass the test cases ?
Last edited by Sedefcho on Wed Jul 20, 2005 5:42 pm, edited 2 times in total.
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz »

nope, I failed one test
sory for my "bad manner" I was so bored of keepin' wa...
anyway your in/out helped me a lot
ACed now, thanks
Last edited by jaracz on Wed Jul 20, 2005 5:44 pm, edited 1 time in total.
keep it real!
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho »

Seems we posted our messages at
the very same time : Wed Jul 20, 2005 5:37 pm

Nice to hear that you got ACC.
Last edited by Sedefcho on Wed Jul 20, 2005 5:41 pm, edited 1 time in total.
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz »

I have a little bit another time : Wed Jul 20, 2005 4:48 pm
is it cheating?? ;)
let's go back to the future:> c'ya
Last edited by jaracz on Tue Aug 08, 2006 12:44 am, edited 1 time in total.
keep it real!
Post Reply

Return to “Volume 4 (400-499)”