若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1514: Automated Judge Script

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,212

题目描述

Human programming contest judges are known to be very picky. To eliminate the need for them, write an automated judge script to judge submitted solution runs.

Your program should take a file containing the correct output as well as the output of submitted program and answer either Accepted, Presentation Error, or Wrong Answer, defined as follows:

Accepted:
You are to report “Accepted'' if the team's output matches the standard solution exactly. All characters must match and must occur in the same order.

Presentation Error:
Give a “Presentation Error'' if all numeric characters match in the same order, but there is at least one non-matching non-numeric character. For example, “15 0'' and “150'' would receive “Presentation Error'', whereas “15 0'' and “1 0'' would receive “Wrong Answer,'' described below.

Wrong Answer:
If the team output cannot be classified as above, then you have no alternative but to score the program a `Wrong Answer'.

输入

The input will consist of an arbitrary number of input sets. Each input set begins with a line containing a positive integer n < 100, which describes the number of lines of the correct solution. The next n lines contain the correct solution. Then comes a positive integer m < 100, alone on its line, which describes the number of lines of the team's submitted output. The next m lines contain this output. The input is terminated by a value of n = 0, which should not be processed.

No line will have more than 100 characters.

输出

For each set, output one of the following:

Run #x: Accepted

Run #x: Presentation Error

Run #x: Wrong Answer

where x stands for the number of the input set (starting from 1).

样例输入

2
The answer is: 10
The answer is: 5
2
The answer is: 10
The answer is: 5
2
The answer is: 10
The answer is: 5
2
The answer is: 10
The answer is: 15
2
The answer is: 10
The answer is:  5
2
The answer is: 10
The answer is: 5
3
Input Set #1: YES
Input Set #2: NO
Input Set #3: NO
3
Input Set #0: YES
Input Set #1: NO
Input Set #2: NO
1
1 0 1 0
1
1010
1
The judges are mean!
1
The judges are good!
0


样例输出

Run #1: Accepted
Run #2: Wrong Answer
Run #3: Presentation Error
Run #4: Wrong Answer
Run #5: Presentation Error
Run #6: Presentation Error


参考代码

#include"stdio.h"
#include"string.h"
char a[101][101],b[101][101];
int ac(int n) 
{
    int i;
    for (i=0;i<n;i++)
            if(strcmp(a[i],b[i])!=0)
                return 0;
    //pe|wa
    return 1;
    //ac 1
}
int pe(int n) 
{
    char c[101]={0},d[101]={0};
    int i,j,k=0;
    for (i=0;i<n;i++)
            for (j=0;a[i][j]!='';j++)
            if(a[i][j]>='0'&&a[i][j]<='9')
                c[k++]=a[i][j];
    k=0;
    for(i=0;i<n;i++)
        for(j=0;b[i][j]!=0;j++)
            if(b[i][j]>='0'&&b[i][j]<='9')
                d[k++]=b[i][j];
    if(strcmp(c,d)==0)
        return 0;//pe
    else
        return 2;//wa
}
int main()
{
    int n,m,i;
    int flag,count=1;//WA 2 PE 0 AC 1
    while(scanf("%d",&n)&&n)
    {
        getchar();
        for(i=0;i<n;i++)
            gets(a[i]);
        scanf("%d",&m);
        getchar();
        for(i=0;i<m;i++)
            gets(b[i]);
        if(n!=m)
            flag=2;//wa
        else
        {
            flag=ac(n);
            if(flag==0)//pe|wa
                flag=pe(n);
        }
        if(flag==1)
            printf("Run #%d: Acceptedn",count++);
        else if(flag==0)
            printf("Run #%d: Presentation Errorn",count++);
        else
            printf("Run #%d: Wrong Answern",count++);
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip Dreams孤独患者 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist