uva-10188-Automated Judge Script

The description:

                        The problem is a simulation of the judges.And, there only three status,as follows:AC,WA and PE.give you the answers and the key,please output the status.it is a easy to understand.

The algorithm:

                     Just judge it.But you must read the problem seriously.espcially when you judge the status of WA and PE.That is , the numberic,you must compare all the number at the same time,do not one line each time.Or else ,you will get a WA like me.

The resorce code:

 

the WA:

//题目理解可能有问题!
/*#include<stdio.h>
#include<string.h>

char str1[110][122],str2[110][122];
char dig1[122],dig2[122];
int m,n,cnt=0;

int max(int s,int t)
{
 return s>t?s:t;
}

void get_num(int t)
{
 memset(dig1,0,sizeof(dig1));
 memset(dig2,0,sizeof(dig2));
 int i,j,len;
 len=strlen(str1[t]);
 for(i=0,j=0;i<len;i++)
 {
  if(str1[t][i]>='0'&&str1[t][i]<='9')
   dig1[j++]=str1[t][i];
 }
 dig1[j]='/0';

 len=strlen(str2[t]);
 for(i=0,j=0;i<len;i++)
 {
  if(str2[t][i]>='0'&&str2[t][i]<='9')
   dig2[j++]=str2[t][i];
 }
 dig2[j]='/0';
}

int solve()
{
 int f1=0,i;
 for(i=0;i<max(m,n);i++)
 {
  if(strcmp(str1[i],str2[i])!=0)
  {
   f1=1;
   get_num(i);
   if(strcmp(dig1,dig2)!=0)
   {
    return 1;
   }
  }
 }
 if(f1==0)
  return 0;
 return 2;
}

int main()
{
 int i,j,flag;
 while(scanf("%d",&m),m)
 {
  getchar();
  cnt++;
  memset(str1,0,sizeof(str1));
  memset(str2,0,sizeof(str2));
  for(i=0;i<m;i++)
   gets(str1[i]);
  scanf("%d",&n);
  getchar();
  for(j=0;j<n;j++)
   gets(str2[j]);
  flag=solve();
  if(flag==0)
   printf("Run #%d: Accepted/n",cnt);
  if(flag==1)
   printf("Run #%d: Wrong Answer/n",cnt);
  if(flag==2)
   printf("Run #%d: Presentation Error/n",cnt);
 }
 return 0;
}
*/

 

the AC:

 

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>

char str1[110][122],str2[110][122];
char dig1[12200],dig2[12200];
int m,n,cnt=0;

int min(int s,int t)
{
 return s<t?s:t;
}

void get_num()
{
 memset(dig1,0,sizeof(dig1));
 memset(dig2,0,sizeof(dig2));
 int i,j,len,t;
 j=0;
 for(t=0;t<m;t++)
 {
  len=strlen(str1[t]);
  for(i=0;i<len;i++)
  {
   if(isdigit(str1[t][i]))
    dig1[j++]=str1[t][i];
  }
 }
 dig1[j]='/0';
 j=0;
 for(t=0;t<n;t++)
 {
  len=strlen(str2[t]);
  for(i=0;i<len;i++)
  {
   if(isdigit(str2[t][i]))
    dig2[j++]=str2[t][i];
  }
 }
 dig2[j]='/0';
}

int solve()
{
 int i,flag=0;
 if(m!=n)
  flag=2;
 for(i=0;i<min(m,n);i++)
 {
  if(strcmp(str1[i],str2[i])!=0||flag==2)
  {
   flag=2;
   get_num();
   if(strcmp(dig1,dig2)!=0)
   {
    flag=1;
    
   }
   break;
  }
 }
 return flag;
}

int main()
{
 int i,j,flag;
 while(scanf("%d",&m),m)
 {
  getchar();
  cnt++;
  memset(str1,0,sizeof(str1));
  memset(str2,0,sizeof(str2));
  for(i=0;i<m;i++)
   gets(str1[i]);
  scanf("%d",&n);
  getchar();
  for(j=0;j<n;j++)
   gets(str2[j]);
  flag=solve();
  if(flag==0)
   printf("Run #%d: Accepted/n",cnt);
  if(flag==1)
   printf("Run #%d: Wrong Answer/n",cnt);
  if(flag==2)
   printf("Run #%d: Presentation Error/n",cnt);
 }
 return 0;
}

 

sum-up:

            I got several WAs because i do not compare the number of the lines. I just compare all according the larger number, that is to say, the one has more lines. However, when I chang to compare them , I got AC. So, we must do the problems logically, or else ,you will be in trouble.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值