HDU 1073 Online Judge(字符串)
Online Judge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4977 Accepted Submission(s): 1889
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.
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.
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
Presentation Error
Presentation Error
Wrong Answer
Presentation Error
题意:代码在线评測。返回三种结果,ac,pe,wa。 非常水的字符串处理,1A。
#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; if (strcmp(sa, sb) != 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;
}
HDU 1073 Online Judge(字符串)的更多相关文章
- HDOJ/HDU 1073 Online Judge(字符串处理~)
Problem Description Ignatius is building an Online Judge, now he has worked out all the problems exc ...
- HDU 1073 Online Judge (字符串处理)
题目链接 Problem Description Ignatius is building an Online Judge, now he has worked out all the problem ...
- 解题报告:hdu 1073 Online Judge
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1073 Problem Description Ignatius is building an Onli ...
- HDU 1073 - Online Judge
模拟评测机判断答案 先判断有没有不一样的 有的话再提取出 有效子列 看看有没有错的 #include <iostream> #include <cstdio> #include ...
- HDU ACM 1073 Online Judge ->字符串水题
分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...
- hdu 1073 字符串处理
题意:给一系列的输出和标准答案,比较二者是AC,PE或WA 字符串处理还是比较薄弱,目前没什么时间搞字符串专题,所以遇到一题就努力搞懂 #include<cstdio> #include& ...
- HDU 1073
http://acm.hdu.edu.cn/showproblem.php?pid=1073 模拟oj判题 随便搞,开始字符串读入的细节地方没处理好,wa了好久 #include <iostre ...
- HDU2112 HDU Today 最短路+字符串哈希
HDU Today Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu 1062 Text Reverse 字符串
Text Reverse Time L ...
随机推荐
- 【KMP】BZOJ3942-[Usaco2015 Feb] Censoring
[题目大意] 有一个S串和一个T串,长度均小于1,000,000,设当前串为U串,然后从前往后枚举S串一个字符一个字符往U串里添加,若U串后缀为T,则去掉这个后缀继续流程.输出最后的S串. [思路]三 ...
- 【优先队列】POJ1442-Black Box
[思路] 建立一个小堆和一个大堆.大堆用来存放第1..index-1大的数,其余数存放在大堆,小堆的堆顶元素便是我们要求出的第index大的数.每次插入一个A(n),必须保证大堆中数字数目不变,故先插 ...
- 通过win下的eclipse连接虚拟机中伪分布的hadoop进行调试
VMware虚拟机配置Ubuntu桥接方式(Bridged)使虚拟机和宿主机能互相ping通, 通过win下的eclipse连接虚拟机中伪分布的hadoop进行调试 1.设置Bridged上网方式 V ...
- 最近公共祖先 LCA 倍增法
[简介] 解决LCA问题的倍增法是一种基于倍增思想的在线算法. [原理] 原理和同样是使用倍增思想的RMQ-ST 算法类似,比较简单,想清楚后很容易实现. 对于每个节点u , ancestors[u] ...
- Android内存优化4 了解java GC 垃圾回收机制2 GC执行finalize的过程
1. finalize的作用 finalize()是Object的protected方法,子类可以覆盖该方法以实现资源清理工作,GC在回收对象之前调用该方法. finalize()与C++中的析构函数 ...
- cpu个数、核数、线程数、Java多线程关系的理解
cpu个数.核数.线程数.Java多线程关系的理解 2017年12月08日 15:35:37 一 cpu个数.核数.线程数的关系 cpu个数:是指物理上,也及硬件上的核心数: 核数:是逻辑上的,简单理 ...
- [转]SSIS Recordset Destination
本文转自:http://www.sqlis.com/sqlis/post/Shredding-a-Recordset.aspx Doing what to a recordset? Shredding ...
- [转]SQL Server 2005 Integration Services (SSIS) (3) - Business Intelligence Development Studio
本文转自:http://blog.csdn.net/me_online/article/details/1546281 三,SQL Server Integration Services 开发环境– ...
- chrome.webRequest
chrome.webRequest 描述: 使用 chrome.webRequest API 监控与分析流量,还可以实时地拦截.阻止或修改请求. 可用版本: 从 Chrome 17 开始支持. 权 ...
- 利用Nodejs & Cheerio & Request抓取Lofter美女图片
还是参考了这篇文章: http://cnodejs.org/topic/54bdaac4514ea9146862abee 另外有上面文章 nodejs抓取网易公开课的一些经验. 代码如下,注意其中用到 ...