HDU 1073 Online Judge(水~)
程序员文章站
2022-03-09 15:17:07
...
Description
给出两个字符串,如果两个字符串完全相同则输出Accepted,如果两个字符串只相差’ ‘,’/t’或’\n’则输出Presentation Error,否则输出Wrong Answer
Input
第一行一整数T表示用例组数,每组用例输入两个字符串,每个字符串输入前先输入START,输入END表示输入结束
Output
如果两个字符串完全相同则输出Accepted,如果两个字符串只相差’ ‘,’/t’或’\n’则输出Presentation Error,否则输出Wrong Answer
Sample Input
Sample Output
Presentation Error
Presentation Error
Wrong Answer
Presentation Error
Solution
设两个串为a和b,先把两个串中的’ ‘,’/t’和’\n’都去掉得到两个字符串aa和bb,如果a和b相同则Accepted,如果aa和bb相同则Presentation Error,否则Wrong Answer
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define maxn 5555
char t[maxn],a[maxn],aa[maxn],b[maxn],bb[maxn];
void deal(char *a,char *aa)
{
gets(t);
while(strcmp(t,"START")!=0)gets(t);
while(gets(t))
{
if(strcmp(t,"END")==0)break;
if(strlen(t))strcat(a,t);
else strcat(a,"\n");
}
int res=0,len=strlen(a);
for(int i=0;i<len;i++)
if(a[i]!=' '&&a[i]!='\t'&&a[i]!='\n')aa[res++]=a[i];
aa[res]='\0';
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
a[0]='\0',b[0]='\0';
deal(a,aa),deal(b,bb);
if(strcmp(a,b)==0)printf("Accepted\n");
else if(strcmp(aa,bb)==0)printf("Presentation Error\n");
else printf("Wrong Answer\n");
}
return 0;
}
上一篇: 新的篇章-总览