zoukankan      html  css  js  c++  java
  • HDU1073 Online Judge【输入输出+字符串】

    Online Judge

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 8329    Accepted Submission(s): 3085

    Problem Description
    Ignatius is building an Online Judge, now he has worked out all the problems except the Judge System. The system has to read data from correct output file and user's result file, then the system compare the two files. If the two files are absolutly same, then the Judge System return "Accepted", else if the only differences between the two files are spaces(' '), tabs(' '), or enters(' '), the Judge System should return "Presentation Error", else the system will return "Wrong Answer".

    Given the data of correct output file and the data of user's result file, your task is to determine which result the Judge System will return.
    Input
    The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
    Each test case has two parts, the data of correct output file and the data of the user's result file. Both of them are starts with a single line contains a string "START" and end with a single line contains a string "END", these two strings are not the data. In other words, the data is between the two strings. The data will at most 5000 characters.
    Output
    For each test cases, you should output the the result Judge System should return.
    Sample Input
    4 START 1 + 2 = 3 END START 1+2=3 END START 1 + 2 = 3 END START 1 + 2 = 3 END START 1 + 2 = 3 END START 1 + 2 = 4 END START 1 + 2 = 3 END START 1 + 2 = 3 END
    Sample Output
    Presentation Error Presentation Error Wrong Answer Presentation Error
    Author
    Ignatius.L

    问题链接HDU1073 Online Judge

    题意简述:参见上文。

    问题分析:这是一个有关输入输出以及字符串处理的问题。

    程序说明:(略)

    题记:(略)


    AC的C++语言程序如下:

    /* HDU1073 Online Judge */
    
    #include <iostream>
    #include <string.h>
    
    using namespace std;
    
    const string START = "START";
    const string END = "END";
    const int N = 5000;
    
    string a1, a2;
    char b1[N+1], b2[N+1];
    
    void input(string& a, char b[])
    {
        string s;
    
        getline(cin, s);
        while(s != START)
            getline(cin, s);
    
        a = "";
        while(getline(cin, s)) {
            if(s == END)
                break;
            a += s + "
    ";
        }
    
        int i = 0, j = 0;
        while(a[i])
            if(a[i] != ' ' && a[i] != '	' && a[i] != '
    ')
                b[j++] = a[i++];
            else
                i++;
        b[j] = '';
    }
    
    int main()
    {
        int t;
    
        cin >> t;
        while(t--) {
            input(a1, b1);
            input(a2, b2);
    
            if(a1 == a2)
                printf("Accepted
    ");
            else if( strcmp(b1, b2) == 0)
                printf("Presentation Error
    ");
            else
                printf("Wrong Answer
    ");
        }
    
        return 0;
    }


  • 相关阅读:
    冒泡排序
    CFURLCreateStringByAddingPercentEscapes
    AESCrypt加密与解密
    关于Xcode 的SDK与系统版本理解
    nginx 安全稳定版本
    bcom 遇到的那些问题
    nginx 配置404错误页面
    AES 对称加密解密
    SpringCloud stream连接RabbitMQ收发信息
    springboot1.5 和 2.0 引入 redis 并封装工具类
  • 原文地址:https://www.cnblogs.com/tigerisland/p/7563632.html
Copyright © 2011-2022 走看看