10188 - Automated Judge Script
Moderator: Board moderators
10188 - Automated Judge Script
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 ?
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 ?
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
gets
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.....

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

i use getchar() and strcat() but got w/a,help!
#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++;
}
}
#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++;
}
}
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
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.
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.
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
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
Yes, you are right. After I change my while(scanf("%d\n",&n)==1) to while(gets(line)!=NULL), I got AC.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.

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.
After changing the way as yatsen does , I got AC.
But I still don't know why can't use
Could anyone explain it clearly? Maybe some examples are helpful.
Thanks!
But I still don't know why can't use
Code: Select all
while(scanf("%d",&n) && n)
scanf("\n");
Thanks!
Last edited by supermin on Sun Jan 12, 2003 3:36 am, edited 1 time in total.
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany