ACM--OJ判题--HDOJ 1073--Online Judge--字符串

HDOJ题目地址:传送门

Online Judge

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 6939    Accepted Submission(s): 2655

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(‘\t‘), or enters(‘\n‘), 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
#include <cstdlib>
#include <string>
#include <iostream>
#include <sstream>
#include <cctype>
using namespace std;
string src, dest, start, end;
char sa[5001], sb[5001];
void readContent(string &s){
    s.clear();
    string ts;
    while (getline(cin, ts)){
        if (ts != "END"){
            s += ts;
            s += "\n";
        }
        else{
            break;
        }
    }
}
void judge(const string &src, const string &dest, bool &af, bool &pf, bool &wf){
    af = pf = wf = false;
    if (src == dest){
        af = true;
        return;
    }
    pf = true;

    int pos = 0;
    for (int i = 0; i < src.length(); ++i){
        if (!isspace(src[i])){
            sa[pos++] = src[i];
        }
    }
    sa[pos] = 0;

    pos = 0;
    for (int i = 0; i < dest.length(); ++i){
        if (!isspace(dest[i])){
            sb[pos++] = dest[i];
        }
    }
    sb[pos] = 0;

    string sa_s,sb_s;
    sa_s=sa;sb_s=sb;
    if(sa_s.compare(sb_s)!=0){
        wf = true;
    }
}

int main(){
    int t;
    bool af, pf, wf;
    cin >> t;
    while (t--){
        cin >> start;
        readContent(src);
        cin >> start;
        readContent(dest);
        judge(src, dest, af, pf, wf);

        if (af){
            cout << "Accepted" << endl;
        }
        else if (wf){
            cout << "Wrong Answer" << endl;
        }
        else{
            cout << "Presentation Error" << endl;
        }
    }
    return 0;
}
时间: 2024-09-29 04:39:52

ACM--OJ判题--HDOJ 1073--Online Judge--字符串的相关文章

HDU ACM 1073 Online Judge -&gt;字符串水题

分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read(char p[]) { getchar(); gets(tmp); while(gets(tmp)) { if(strcmp(tmp,"END")==0) break; if(strlen(tmp)!=0) strcat(p,tmp); strcat(p,"\n");

HDOJ/HDU 1073 Online Judge(字符串处理~)

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 f

ZZNU 1163: 在线判题(指针专题)

题目描述 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 absolu

九度OJ刷题——1002:Grading

题目描述: Grading hundreds of thousands of Graduate Entrance Exams is a hard work. It is even harder to design a process to make the results as fair as possible. One way is to assign each exam problem to 3 independent experts. If they do not agree to eac

ACM OJ Collection

浙江大学(ZJU):http://acm.zju.edu.cn/ 北京大学(PKU):http://acm.pku.edu.cn/JudgeOnline/ 同济大学(TJU):http://acm.tongji.edu.cn/ 宁波理工(NIT):http://acm.nit.net.cn 中国地质大学(CUG):http://lab.cug.edu.cn/COJ/ 中国科技大学(USTC):http://acm.ustc.edu.cn/ 吉林大学(jlu):http://acm.jlu.edu

ACM 暴力搜索题 题目整理

UVa 129 Krypton Factor 注意输出格式,比较坑爹. 每次要进行处理去掉容易的串,统计困难串的个数. #include<iostream> #include<vector> #include<cmath> #include<map> #include<algorithm> #include<cstring> #include<cstdio> #include<cstdlib> #include

OnlineJudge判题平台 ——后台流程

判题分两部分 1.其中judged为服务进程,d即daemon.负责轮询数据库,提取判题队列.当发现新任务时产生judge_client进程. 2.judge_client进程为实际判题程序,负责准备运行环境.数据,运行并监控目标程序的系统调用,采集运行指标,判断运行结果. Judged流程 初始化: 1.创建子进程pid_judged,并设置为会话的领头进程(umask(0),close(0~2)) 2.改变当前工作目录为"/home/judge" 3.将pid_judged写入文件

牛客网在线判题系统JavaScript(V8)使用

JavaScript作为一种弱类型的编程语言,语法和C/C++.JAVA等存在差别,但是对于大部算法题,不只是C/C++.JAVA,也依然可以使用JavaScript来实现.所以在牛客网中,如果你喜欢JavaScript这门编程语言,同时对数据结构与算法感兴趣,当然可以使用这门语言去刷编程题. 大家有没有跟我碰到过和我类似的情况,在牛客网刷编程题的时候,编译器提供的是Javascript(v8 6.0.0),在线编程部分前端编程还好,只用在题目给出的函数中补充就行.但苦恼的是,我们不知道如何像C

华为OJ训练题之 比赛情况统计

题目如下: 比赛情况统计 有一个游戏平台,各个参赛队伍(以唯一的TeamID来标识)之间进行单循环的对抗赛,两个队伍之间只举行一场比赛,比赛以得分的多少定胜负.需要完成一个统计赛况的程序,能够随时查询指定队伍的最新赛况:包括胜.平.负的局数,当前总积分以及名次. 说明:循环赛没有全部结束时也可以查询某个队伍的最新赛况 规则说明 比赛判定:两个队伍中得分高的一方为胜者,另一方为负者:得分相同则为平局 积分规则:每一局比赛: 胜者积3分;平局双方各积1分; 负者积0分 排名规则:按照当前总积分的高低