Page 1 of 4

10188 - Automated Judge Script

Posted: Tue Jun 18, 2002 8:54 pm
by Caesum
The problem seems simple enough, but why so many WA's on this question, and why do I keep getting WA ?

I compare digits of both input:
If not equal then the answer is WA
I compare inputs in entirety:
If not equal then the answer is PE
Otherwise the answer is AC

A lot of people in the comments are making comments about spaces and \n's but this is not what the question is stating. The question clearly states:
ALL characters must match and must be in the same order
and ALL has been put into capitals for emphasis. Removing spaces and \n's does not help. (note: backslashes might not show up in forum)

So can anyone confirm what is wrong with this one ? Presumably there is some bad judge data here ?

Posted: Tue Jun 18, 2002 10:14 pm
by Ivan Golubev
How do you read input? If you're using scanf() you can get incorrect results (PE instead of AC), so best choice is to use only gets().

gets

Posted: Tue Jun 18, 2002 10:23 pm
by Caesum
Actually I am using gets...... and I just thought a bit more carefully about this and realised that gets removes the newline character which was causing my problem since I simply concatenated all input together without newlines. Added a strcat(lines,"\n") before adding the next line and it works perfectly :)

Was mislead by peoples comments in their tag lines..... :oops:

help!

Posted: Wed Aug 28, 2002 2:27 pm
by liusu
i got WA again and again,please help me?what's the problem?or give me some sample input and output?
:oops:

i use getchar() and strcat() but got w/a,help!

Posted: Thu Sep 12, 2002 3:54 pm
by chaojinn
#include "iostream.h"
#include "string.h"
#include "stdio.h"
#include "fstream.h"

void noblank(char str[])
{
long l=strlen(str);
long i,j;
for(i=0;i<l;i++)
{
if(!(str>='0'&&str<='9'))
{
for(j=i;j<l-1;j++)
{
str[j]=str[j+1];
}
l--;
str[l]='\0';
i=-1;
}
}
}

void main()
{
bool ac,wa,pe;
long index=1;
long n;
while(cin>>n)
{
if(n==0)
break;
ac=wa=pe=false;
char table[12000];
strcpy(table,"");
long i=0;
while(i<n)
{
char t=getchar();
if(t=='\n')
i++;
char tt[2];
tt[0]=t;
tt[1]='\0';
strcat(table,tt);
}
long nn;
cin>>nn;
char tab[12000];
strcpy(tab,"");
i=0;
while(i<nn)
{
char t=getchar();
if(t=='\n')
i++;
char tt[2];
tt[0]=t;
tt[1]='\0';
strcat(tab,tt);
}
if(strcmp(table,tab))
{
noblank(table);
noblank(tab);
if(!strcmp(table,tab))
{
pe=true;
}
else
{
wa=true;
}

}
if((!wa)&&(!pe))
ac=true;
if(wa)
cout<<"Run #"<<index<<": Wrong Answer"<<endl;
if(pe)
cout<<"Run #"<<index<<": Presentation Error"<<endl;
if(ac)
cout<<"Run #"<<index<<": Accepted"<<endl;
index++;
}



}

Posted: Sat Dec 07, 2002 6:08 pm
by dabendan
what is the output if my input is:
3
Input Set #1: YES
Input Set #2: NO
Input Set #3: NO
4
123
ABCDE FG
hij k
lmn
0

Posted: Mon Dec 23, 2002 7:29 pm
by deddy one
I get runtime error sigsegv for this
what is invalid memory reference? could anyone helped me out?
I used 4 char array with 1000 array of element each for this problem.

Posted: Tue Dec 24, 2002 8:08 am
by yatsen
Can anyone who got AC put some test cases?
I got WA but I do not know what is wrong. Thanks.

Posted: Tue Dec 24, 2002 10:34 am
by deddy one
ok I've taken care of sigsegv, now I get WA like everyone else here, well except for Caesum and Ivan of course, it run 0.025 sec before it declared to be WA.
ummm, same question with yatsen pls

Posted: Tue Dec 24, 2002 1:56 pm
by Ivan Golubev
I think that input reading routine is a most important part in this problem. Once you've read everything correct, everything else is trivial.

In my accepted solution this part looks like:[c] while (gets(s) != NULL) {
n1 = atol(s);
if (n1 == 0) break;
p1 = (char *)malloc(128 * n1);
for (i=0; i<n1; i++) gets(&p1[i*128]);
gets(s);
n2 = atol(s);
p2 = (char *)malloc(128 * n2);
for (i=0; i<n2; i++) gets(&p2[i*128]);
...
}[/c]Now you can compare these strings like:[c]if (strcmp(&p1[index1*128], &p2[index2*128])) ...[/c]And, of course, don't forget to free p1 & p2 after calculations.

And correct answer for dabendan's input is PE.

Posted: Tue Dec 24, 2002 2:18 pm
by deddy one
aaaaah

I've found my mistake , after changing the line

strcpy (result,"");

into

for (i=0;i<MAX;i++)
result = '\0';

it get accepted right away.
and also I used the strcat (result,"\n") like Caesum said
it worked out fine.

let me give sample input
3
adfs df 1 dasf adf df
2
fs aaaaaaaaaaaa 3
3
aa1
2
3

sample output
Run #1: Presentation Error

Posted: Wed Dec 25, 2002 9:01 am
by yatsen
Ivan Golubev wrote:I think that input reading routine is a most important part in this problem. Once you've read everything correct, everything else is trivial.
Yes, you are right. After I change my while(scanf("%d\n",&n)==1) to while(gets(line)!=NULL), I got AC. :D

But my check order is different from Caesum's.
I check AC first, then check PE, otherwise WA.
I think it is easier for me.

Posted: Sat Jan 11, 2003 8:17 pm
by supermin
After changing the way as yatsen does , I got AC.

But I still don't know why can't use

Code: Select all

while(scanf("%d",&n) && n)  
    scanf("\n");
Could anyone explain it clearly? Maybe some examples are helpful.

Thanks!

Posted: Sat Jan 11, 2003 8:50 pm
by Adrian Kuegel
scanf("\n") does not only read one '\n' character, it does read all whitespace characters. Try it out!

Posted: Sun Jan 12, 2003 3:35 am
by supermin
Oh , I see . Thank you very much! :D