• UVa 10188 Automated Judge Script


     

    Problem A: Automated Judge Script

    The Problem

    The judges from the programming contests are known to be very mean and very lazy. We, judges, want less work and more Wrong Answers! So, we'd like you to help us and write an automated judge script to judge solution runs from teams all over the world. All you have to do is write a program which receives the standard solution and a team output and gives as answer one of the following messages: "Accepted", "Presentation Error" or "Wrong Answer". We define each one as:

    Accepted: As we are very mean judges, we only want you to give "Accepted" as answer if the team output matches the standard solution integrally. That is, ALL characters must match and must be in the same order.

    Presentation Error: We want you to give "Presentation Error" if all NUMERIC charaters match (and in the same order) but there is at least one non-numeric character wrong (or in wrong order).  For instance, "15 0" and "150" would receive a "Presentation Error", whereas "15 0" and "1 0" would not (it would receive "Wrong Answer", see bellow).

    Wrong Answer: If the team output could not be classified as any of the two above, then you have no option but to give "Wrong Answer" as an answer!

    The Input

    The input will consist of an arbitrary number of input sets. Each input set begins with a positive integer n < 100, alone in a line, which describes the number of lines of the standard solution. The next n  lines contain the standard solution. Then there is a positive integer m < 100, alone in a line, which describes the number of lines of the team output. The next m lines contain the team output. The input is terminated by a value of n = 0, and should not be processed. No line will have more than 120 characters.

    The Output

    For each set you should output one of the following lines:

    Run #x: Accepted
    Run #x: Presentation Error
    Run #x: Wrong Answer
    

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

    Sample Input

    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
    

    Sample Output

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

    源代码:

    #include<iostream>

    #include<string>

    #include<cstring>

    #include<cstdio>

    using namespace std;

     

    int n,m;

    string str1[100],str2[100];

    char ch1[10001],ch2[10001];

    bool strNumCmp()

    {

        int i,j,k;

        j=0;

        memset(ch1,0,10001);

        memset(ch2,0,10001);

        for(i=0;i<n;++i)

        {

            for(k=0;k<str1[i].size();++k)

            {

                if(str1[i][k]>='0' && str1[i][k]<='9')

                    ch1[j++]=str1[i][k];

            }

        }

        ch1[j]='\0';

        j=0; 

        for(i=0;i<m;++i)

        {

            for(k=0;k<str2[i].size();++k)

            {

                if(str2[i][k]>='0' && str2[i][k]<='9')

                    ch2[j++]=str2[i][k];

            }

        }

        ch2[j]='\0';

        if(strcmp(ch1,ch2)==0) return true;

        else return false;                  

    }

    int main()

    {

        int i,num;

        num=1;

        while(1)

        {

            bool pflag,wflag;

            cin>>n;

            getchar();

            if(n==0) break;

            for(i=0;i<n;++i)

                getline(cin,str1[i]);

            cin>>m;

            getchar();

            for(i=0;i<m;++i)

                getline(cin,str2[i]);

            pflag=wflag=false;

            if(n!=m){

                if(strNumCmp()) pflag=true;

                else wflag=true;         

            }

            else{

                for(i=0;i<n;++i)

                {

                    if(str1[i]!=str2[i]) break;

                }

                if(i!=n)

                {

                    if(strNumCmp()) pflag=true;

                    else wflag=true;

                }

            }

            if(wflag) cout<<"Run #"<<num++<<": Wrong Answer"<<endl;

            else if(pflag) cout<<"Run #"<<num++<<": Presentation Error"<<endl;

            else cout<<"Run #"<<num++<<": Accepted"<<endl;

        }

        return 0;

    }

     //原来提交一直错误,主要是因为没有清题,当格式不对时,要判断所有的数字字符的顺序是否正确(原来我是每行判断的)

    如:

    3

    11

    11

    11

    1

    111111

    答案应该是:Presentation Error

    还有就是当m!=n时,直接判断是否为Presentation Error就行了

    3

    11

    12

    13

    4

    11

    1

    2

    13

    答案应该是:Presentation Error

    而对于:

    3

    11

    12

    13

    4

    11

    12

    13

    14

    就应该是Wrong Answer

  • 相关阅读:
    【计算机视觉】计算机视觉、模式识别、机器学习常用牛人主页链接
    【计算机视觉】Emvisi2
    【计算机视觉】Emvisi2
    【计算机视觉】阶编码本模型(Multi phase codebook model)
    【计算机视觉】阶编码本模型(Multi phase codebook model)
    【计算机视觉】非参数背景模型介绍
    【计算机视觉】非参数背景模型介绍
    【计算机视觉】非参数背景模型介绍
    【计算机视觉】非参数背景模型介绍
    【计算机视觉】常用背景模型介绍
  • 原文地址:https://www.cnblogs.com/redlight/p/2295945.html
Copyright © 2020-2023  润新知