随笔分类 -  ACM — 字符串

摘要:这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿;题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了:http://acm.hdu.edu.cn/showproblem.php?pid=2629 1 #include 2 #include 3 using namespace std; 4 int main() 5 { 6 int n,t; 7 string home,a; 8 cin>>n; 9 for(int k = 0 ; k >a;12 t = (a[0]-'0')*10+a[1]-'0';13 s... 阅读全文
posted @ 2013-12-10 14:34 crazy_apple 阅读(2025) 评论(0) 推荐(0)
摘要:#include#include#includeusing namespace std;char str[20000];int work(int m){ int i,j,l; i=0; j=1; while(im) break; if(str[(i+l)%m] > str[(j+l)%m]) i=i+l+1; else j=j+l+1; if(i==j) j=i+1; } if(i<j) return i; return j;}int main(){ int text... 阅读全文
posted @ 2013-10-30 17:13 crazy_apple 阅读(653) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=33647【题意】:字符串匹配,暴力配就行了【题解】:截出单词,然后进行匹配就行了【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 char tstr[100][100]; 9 10 int main()11 {12 int t;13 scanf("%d",&t);14 getchar();15 while(t--)16 {17 ... 阅读全文
posted @ 2013-10-05 14:50 crazy_apple 阅读(284) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29375【题意】:可以对两字符串进行如下操作: 1、可以无损耗交换相邻两个字符(可以理解成交换任意字符) 2、可以改变一个字符 x->y,花费为 x-y 的绝对值 求花费最少,将两字符串变成一样【题解】: 排序字符串,然后对应相减【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 char str1[100010],str2[100010]; 9 10 int abs(int... 阅读全文
posted @ 2013-10-04 14:18 crazy_apple 阅读(284) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=4352【题意】:给你个长串,输出该长串中能第一放出的技能,每个技能有对应的一个小子串,不能放出任何技能输出“Nothing Happened”【题解】:暴力匹配(数据量不大),若数据量巨大,则得用ac自动机解【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 #define INF 1e9 8 9 struct Nod10 {11 char str1[40];12 ... 阅读全文
posted @ 2013-09-17 20:19 crazy_apple 阅读(277) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1403Longest Common SubstringTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3068 Accepted Submission(s): 1087 Problem DescriptionGiven two strings, you have to tell the length of the Longest Common Substr 阅读全文
posted @ 2013-07-19 10:44 crazy_apple 阅读(404) 评论(0) 推荐(0)
摘要:Milk PatternsTime Limit:5000MSMemory Limit:65536KTotal Submissions:7938Accepted:3598Case Time Limit:2000MSDescriptionFarmer John has noticed that the quality of milk given by his cows varies from day to day. On further investigation, he discovered that although he can't predict the quality of mi 阅读全文
posted @ 2013-07-19 10:32 crazy_apple 阅读(259) 评论(0) 推荐(0)
摘要:http://ac.nbutoj.com/Problem/view.xhtml?id=1441[1441] Babelfish时间限制: 1000 ms 内存限制: 65535 K问题描述You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.输入Input consists of u 阅读全文
posted @ 2013-04-26 20:06 crazy_apple 阅读(220) 评论(0) 推荐(0)
摘要:https://vijos.org/p/1167描述自从到了南蛮之地,孔明不仅把孟获收拾的服服帖帖,而且还发现了不少少数民族的智慧,他发现少数民族的图腾往往有着一种分形的效果(看Hint),在得到了酋长的传授后,孔明掌握了不少绘图技术,但唯独不会画他们的图腾,于是他找上了你的爷爷的爷爷的爷爷的爷爷……帮忙,作为一个好孙子的孙子的孙子的孙子……你能做到吗?格式输入格式每个数据一个数字,表示图腾的大小(此大小非彼大小) n<=10输出格式这个大小的图腾样例1样例输入1[复制]2样例输出1[复制] /\ /__\ /\ /\/__\/__\init:提示:#include<iostrea 阅读全文
posted @ 2013-04-08 20:09 crazy_apple 阅读(593) 评论(0) 推荐(0)
摘要:hdu 1234 开门人和关门人Problem Description每天第一个到机房的人要把门打开,最后一个离开的人要把门关好。现有一堆杂乱的机房签到、签离记录,请根据记录找出当天开门和关门的人。Input测试输入的第一行给出记录的总天数N ( > 0 )。下面列出了N天的记录。每天的记录在第一行给出记录的条目数M ( > 0 ),下面是M行,每行的格式为证件号码 签到时间 签离时间其中时间按“小时:分钟:秒钟”(各占2位)给出,证件号码是长度不超过15的字符串。Output对每一天的记录输出1行,即当天开门和关门人的证件号码,中间用1空格分隔。注意:在裁判的标准测试输入中,所有 阅读全文
posted @ 2013-04-04 16:46 crazy_apple 阅读(201) 评论(0) 推荐(0)
摘要:hdu 2074 叠筐Problem Description需要的时候,就把一个个大小差一圈的筐叠上去,使得从上往下看时,边筐花色交错。这个工作现在要让计算机来完成,得看你的了。Input输入是一个个的三元组,分别是,外筐尺寸n(n为满足0<n<80的奇整数),中心花色字符,外筐花色字符,后二者都为ASCII可见字符;Output输出叠在一起的筐图案,中心花色与外筐花色字符从内层起交错相叠,多筐相叠时,最外筐的角总是被打磨掉。叠筐与叠筐之间应有一行间隔。Sample Input11 B A5 @ WSample Output AAAAAAAAA ABBBBBBBBBAABAAAAA 阅读全文
posted @ 2013-04-04 16:37 crazy_apple 阅读(1554) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4287Problem Description We all use cell phone today. And we must be familiar with the intelligent English input method on the cell phone. To be specific, the number buttons may correspond to some English letters respectively, as shown below: 2 : a, b, c3 :.. 阅读全文
posted @ 2012-09-10 21:06 crazy_apple 阅读(366) 评论(0) 推荐(0)
摘要:Problem DescriptionWhen you go shopping, you can search in repository for avalible merchandises by the computers and internet. First you give the search system a name about something, then the system responds with the results. Now you are given a lot merchandise names in repository and some queries, 阅读全文
posted @ 2012-08-29 23:57 crazy_apple 阅读(147) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2001http://acm.hnu.cn/online/?action=problem&type=show&id=10338ShortestPrefixesTime Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KBTotal submit users: 50, Accepted users: 48Problem 10338 : No special judgementProblem descriptionA prefix of a string is 阅读全文
posted @ 2012-08-28 18:05 crazy_apple 阅读(236) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1247Problem DescriptionA hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.You are to find all the hat’s words in a dictionary.InputStandard input consists of a number of lowercase words, one per li 阅读全文
posted @ 2012-08-27 16:36 crazy_apple 阅读(167) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1671Problem DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers:1. Emergency 9112. Alice 97 625 9993. Bob 91 12 54 26In this case, it 阅读全文
posted @ 2012-08-27 11:27 crazy_apple 阅读(152) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1251Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串.注意:本题只有一组测试数据,处理到文件结束.Output对于每个提问,给出以该字符串为 阅读全文
posted @ 2012-08-26 18:20 crazy_apple 阅读(198) 评论(0) 推荐(0)