hdu 1073 字符串处理

题意:给一系列的输出和标准答案,比较二者是AC,PE或WA

字符串处理还是比较薄弱,目前没什么时间搞字符串专题,所以遇到一题就努力搞懂

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<queue>
 7 #include<map>
 8 using namespace std;
 9 #define MOD 1000000007
10 const double eps=1e-5;
11 #define cl(a) memset(a,0,sizeof(a))
12 #define ts printf("*****\n");
13 const int MAXN=6005;
14 char a1[MAXN],a2[MAXN],b1[MAXN],b2[MAXN];
15 int n,m,tt;
16 char temp[MAXN];
17 void in(char a[],char b[])
18 {
19     gets(temp);
20     while(strcmp(temp,"START")!=0)    gets(temp);   //START之前的都去掉
21     while(gets(temp))
22     {
23         if(strcmp(temp,"END")==0)   break;
24         if(strlen(temp)!=0) strcat(a,temp); //读入的不为换行符
25         strcat(a,"\n");
26     }
27     int t=0;
28     for(int i=0;i<strlen(a);i++)
29     {
30         if(a[i]!=‘ ‘&&a[i]!=‘\n‘&&a[i]!=‘\t‘)   //\t要加,因为题目中有要求,汗
31         {
32             b[t++]=a[i];
33         }
34     }
35     b[t]=‘\0‘;  //注意这个一定要加,否则没办法比较
36 }
37 int main()
38 {
39     int i,j,k;
40     #ifndef ONLINE_JUDGE
41     freopen("1.in","r",stdin);
42     #endif
43     scanf("%d",&tt);
44     while(tt--)
45     {
46         a1[0]=‘\0‘;
47         a2[0]=‘\0‘;
48         in(a1,b1);
49         in(a2,b2);
50         if(strcmp(a1,a2)==0)    printf("Accepted\n");       //未被删除格式前都相同,说明完全相同
51         else if(strcmp(b1,b2)==0)   printf("Presentation Error\n");
52         else printf("Wrong Answer\n");
53     }
54 }
时间: 2024-08-05 08:54:37

hdu 1073 字符串处理的相关文章

hdu 2721(字符串处理,位运算 暴力)

Persistent Bits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 201    Accepted Submission(s): 116 Problem Description WhatNext Software creates sequence generators that they hope will produce

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

解题报告:hdu 1073 Online Judge

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1073 题目是英文,在这里用中文显示: 伊格内修斯正在建立一个在线法官,现在他已经研究出除法官系统以外的所有问题.系统必须从正确的输出文件和用户的结果文件读取数据,然后系统比较这两个文件.如果两个文件绝对相同,则判定系统返回"Accepted",否则如果两个文件之间的唯一区别是空格('  '),制表符('\t')或输入('\n'),法官系统应返回"Presentation Erro

hdu 3973 字符串hash+线段树

http://acm.hdu.edu.cn/showproblem.php?pid=3973 Problem Description You are given some words {Wi}. Then our stupid AC will give you a very long string S. AC is stupid and always wants to know whether one substring from S exists in the given words {Wi}

hdu 4821 字符串hash+map判重 String (长春市赛区I题)

http://acm.hdu.edu.cn/showproblem.php?pid=4821 昨晚卡了非常久,開始TLE,然后优化了之后,由于几个地方变量写混.一直狂WA.搞得我昨晚都失眠了,,. 这几次hash军写错的变量--tmp=(j==m-1)?ah[j]:(ah[j]-ah[j-m]*base[m]);  外层循环变量是i,我写的字符串hash的几题都写成tmp=(i==0)? ah[j]:(ah[j]-ah[j-m]*base[m]); 二逼啊 题目大意: 给定一个字符串(最长10^

HDU 1073 Online Judge

字符串比较,3种结果:AC,PE,WA:为了好处理中间的数据让所有输入的字符串连起来并且让两种输入的行数相同,(除却空行) 一个输入函数,一个处理函数 附代码 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int N=5005; 6 void input(char s[]) { 7 s[0]='\0'; 8 char tmp[N]

hdu 4850 字符串构造---欧拉回路构造序列 递归+非递归实现

http://acm.hdu.edu.cn/showproblem.php?pid=4850 题意:构造长度为n的字符序列,使得>=4的子串只出现一次 其实最长只能构造出来26^4+4-1= 456979 的序列,大于该数的都是不可能的.构造方法,就是那种欧拉回路的序列,此题DFS会爆栈,手动扩展栈也可以AC...... 递归形式的开始WA了,没有细调就换非递归了,后来又想了想,虽然自己电脑上运行不了,但是先把长度按小的来,然后调试代码,然后在扩大,AC了,当时错在MOD,递归的MOD应该是26

hdu 1880 字符串hash

/*普通的hsah 由于元素太多 空间很小..hash碰撞很厉害.30分*/ #include<iostream> #include<cstdio> #include<cstring> #include<map> #define maxn 100010 #define mod 2000007 #define hs 117 using namespace std; int n,l,k,cnt,f[mod+10],l1[maxn],l2[maxn]; char

HDU 1228 字符串到数字的转化

一道水题,练练字符串的输入输出 1 #include <cstdio> 2 #include <cstring> 3 4 using namespace std; 5 char s1[15] , s2[15]; 6 7 int get_num(char *s) 8 { 9 if(s[0] == 'z') return 0; 10 else if(s[0] == 'o') return 1; 11 else if(s[0] == 't' && s[1] == 'w')