Page 1 of 11

Posted: Sat Jan 19, 2002 5:41 pm
by FlyDeath
can someone tell me what's the common problems with this question??
thanks

Posted: Sat Jan 19, 2002 7:07 pm
by ..
If there is one,
I think that is the encrypted message may be > 80 characters...

Posted: Sun Jan 20, 2002 5:36 am
by FlyDeath
I find my mistake
thanks

Serious problem about 444

Posted: Sun May 26, 2002 1:56 pm
by Sherman MXF
Help!
Why I got a SIGSEGV runtime error during 444?
I have modified my source for over 10 times!!! :o

Hi!

Posted: Tue May 28, 2002 4:36 pm
by cyfra
Hi!

I had the similar problem...

the only thing you have to do is to make one if...
There is a test case with empty line...

And my program tried to read from ..
I don't know from :)

And it gave R.E.

So make one if in your program and you will propably have A.C.

I hope it will help

Good Luck :wink:

Posted: Thu May 30, 2002 11:53 am
by Subeen
i had similar problem (R.E.) but when I increased the array size from 80 to 400 it got AC. gook luck :P

Posted: Tue Jun 11, 2002 6:32 pm
by Ivan Silva
So if there is a blank line in the input what should we print?
a \n
or just ingore that input?

Cause my arrays size are 400 and my program is ignoring the blank lines...
but i still got WA, and of course the output is correct for the given input :)

-Ivan

I got accepted!

Posted: Wed Jun 12, 2002 5:25 am
by Sherman MXF
:D
When there is a blank input, I just print a blank line.
Then I got ACCEPT!
Thanks to everybody!
:D

Problem 444(Encoder and Decoder) again if you please

Posted: Sun Jun 23, 2002 8:32 pm
by mido
What's wrong with this...I get a wrong answer :-? :
[cpp]
#include <iostream.h>
#include <string.h>

char *str,*res,*res2,temp;
int i,j,num,ones,tens,hundreds;

void main()
{
str=new char[85];
res=new char[85];
res2=new char[270];
while (cin.getline(str,85,'\n'))
{
if (str[0]>='0' && str[0]<='9')
{
j=0;
for (i=0;i<strlen(str)/2;i++)
{
temp=str;
str=str[strlen(str)-1-i];
str[strlen(str)-1-i]=temp;
}
i=0;
while (i<strlen(str))
{
num=0;
if (str=='1')
{
num+=100;
i++;
}
num+=(int(str)-int('0'))*10;
num+=int(str[i+1])-int('0');
i++;
i++;
res[j]=char(num);
j++;
}
res[j]=0;
for (j=0;j<strlen(res);j++)
cout<<res[j];
cout<<endl;
}
else
{
i=0;
j=0;
while (i<strlen(str))
{
num=0;
num=int(str);
if (num<=100)
{
ones=num%10;
tens=(num/10)%10;
res2[j+1]=char(ones+int('0'));
res2[j]=char(tens+int('0'));
j++;
j++;
}
else
{
ones=num%10;
tens=(num/10)%10;
hundreds=(num/100);
res2[j+2]=char(ones+int('0'));
res2[j+1]=char(tens+int('0'));
res2[j]=char(hundreds+int('0'));
j++;
j++;
j++;
}
i++;
}
res2[j]=0;
for (j=j-1;j>=0;j--)
cout<<res2[j];
cout<<endl;
}
}
}
[/cpp]

Posted: Sun Jun 23, 2002 8:56 pm
by 10153EN
I read your code and found nth wrong (without testing of course =P). But I found one minor problem, I donno if it matters.

The input line read in should not be <= 80, since if the text is an encoded text, the length of the text may be > 80.

Posted: Sun Jun 23, 2002 10:44 pm
by mido
Hmmm...well I tried to enlarge the arrays to tens of thousands...still WA...try again, I guess..thanks in advance

Posted: Sun Jun 23, 2002 11:02 pm
by mido
Yikes..found a nasty bug..there's a line saying
if (num<=100)
Should have been [if num < 100]..in other words the letter 'd'(ascii 100) would mess up the thing..harsh world, I guess.

Oh look I got accepted. Thanks 10153EN.

ACM 444

Posted: Wed Jul 03, 2002 1:53 pm
by htl
I think the code doens't have any bug. What's wrong with the code?
[c]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void main(void)
{
int code[80],x,y,temp;
char buffer[1000],c;
while(1)
{
for(x=0;(c=getchar())!='\n';x++)
if(c==EOF)
exit(0);
else
buffer[x]=c;
buffer[x]='\0';
if(buffer[0]>='0' && buffer[0]<='9')
{
for(x=0,y=strlen(buffer)-1;x<y;x++,y--)
{
c=buffer[x];
buffer[x]=buffer[y];
buffer[y]=c;
}
for(x=0,temp=0;buffer[x]!='\0';x++)
{
temp=temp*10+buffer[x]-'0';
if(temp>30)
{
printf("%c",temp);
temp=0;
}
}
printf("\n");
}
else
{
for(x=0,y=strlen(buffer)-1;y>=0;x++,y--)
code[x]=buffer[y];
for(x=0;x<strlen(buffer);x++)
if(code[x]>=100)
printf("%d%d%d",code[x]%10,code[x]%100/10,code[x]/100);
else
printf("%d%d",code[x]%10,code[x]/10);
printf("\n");
}
}
}
[/c]

Posted: Wed Jul 03, 2002 3:04 pm
by Picard
i think, nothing. it got accepted for me.

Posted: Wed Jul 03, 2002 6:34 pm
by htl
I've sent it and got accepted. I just don't know why I couldn't get accepted before? The only difference is the length of buffer is 1000 not 100.