Problem Description Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recentl…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2328 题意:多组输入,n==0结束.给出n个字符串,求最长公共子串,长度相等则求字典序最小. 题解:(居然没t,可能数据水了吧)这个题和 HDU - 1238 基本一样,用string比较好操作.选第一个字符串然后两层循环(相当于找到所有的子串),然后和其他几个字符串比较看是否出现过,如果所有字符串中都出现了就记录下来,找出长度最大字典序最小的子串.否则输出"IDENTITY LOST".…
Description Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recently asked…
题目链接:  HDU http://acm.hdu.edu.cn/showproblem.php?pid=2328 POJhttp://poj.org/problem?id=3450 #include<iostream> #include<cstring> #include<string> #include<cstdio> using namespace std; const int maxn=4444; char x[222],ans[222]; char…
这个问题,需要一组字符串求最长公共子,其实灵活运用KMP高速寻求最长前缀. 请注意,意大利愿父亲:按照输出词典的顺序的规定. 另外要提醒的是:它也被用来KMP为了解决这个问题,但是很多人认为KMP使用的暴力方法,没有真正处理的细节.发挥KMP角色.而通常这些人都大喊什么暴力法能够解决本题,没错,的确暴力法是能够解决本题的,本题的数据不大,可是请不要把KMP挂上去,然后写成暴力法了.那样会误导多少后来人啊. 建议能够主要參考我的getLongestPre这个函数,看看是怎样计算最长前缀的. 怎么推…
枚举长度最短的字符串的所有子串,再与其他串匹配. #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cstdlib> #include<string> #include<cmath> #include<vector> using namespace std; ; ; ); const int in…
分析:基础的练习............... ======================================================================================= #include<stdio.h> #include<string.h> ; void GetNext(char s[], int next[], int N) { , j=-; while(i<N) { || s[i]==s[j]) next[++i]…
http://acm.hdu.edu.cn/showproblem.php?pid=2328 Corporate Identity Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 698    Accepted Submission(s): 281 Problem Description Beside other services, AC…
Corporate Identity Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3308    Accepted Submission(s): 1228 Problem Description Beside other services, ACM helps companies to clearly state their “cor…
Corporate Identity Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5493   Accepted: 2015 Description Beside other services, ACM helps companies to clearly state their "corporate identity", which includes company logo but also other…
Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recently asked ACM for a he…
Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recently asked ACM for a he…
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2328 题目: Corporate Identity Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1599    Accepted Submission(s): 614 Problem Description Beside other serv…
Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recently asked ACM for a he…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2287    Accepted Submission(s): 713 Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.For…
其实和昨天写的那道水题是一样的,注意爆LL $1<=n,k<=1e9$,$\sum\limits_{i=1}^{n}(k \mod i) = nk - \sum\limits_{i=1}^{min(n,k)}\lfloor\frac{k}{i}\rfloor i$ /** @Date : 2017-09-21 19:55:31 * @FileName: HDU 2620 分块底数优化 暴力.cpp * @Platform: Windows * @Author : Lweleth (SoungE…
Corporate Identity Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 7662   Accepted: 2644 Description Beside other services, ACM helps companies to clearly state their "corporate identity", which includes company logo but also other…
题目链接:https://vjudge.net/problem/POJ-3450 Corporate Identity Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 8046   Accepted: 2710 Description Beside other services, ACM helps companies to clearly state their “corporate identity”, which i…
题目大意:给你N(2-4000)个字符串,求出来他们的共同子串   分析:因为上次就说了再出现这种题就不用那种暴力的做法了,于是看了一些别的知识,也就是后缀树,把一个字符串的所有的后缀全部都加入字典树,然后用别的串去匹配,这样匹配的时候速度那是飕飕的啊,不过第一次我把前N-1个串的所有前缀搞进了字典树里面,然后想如果某个节点被访问N-1次,并且第N个串也能访问到此节点,那么这一定就是他们的共同子串了,不过总归是太天真,直接返回MLE,一细琢磨,想着最糟糕的情况也就是有8000(N)个串,每个串都…
[链接]h在这里写链接 [题意] 找一个字典序最小的公共最长子串; [题解] 后缀数组. 把所有的串用不同的分隔符分开.(大于'z'的分隔符); 然后求出那几个固定的数组. 二分一下那个子串的长度. 看看是不是在N个串里面都有这个串即可. 可以用一个下标,来记录某个位置开始的后缀是第几个串里面的(即输入的N个串里面的哪一个串). 子串长度越大显然越不可能存在. (因子本来就是按照后缀排的.所以找到的第一个符合要求的子串肯定是字典序最小的) [错的次数] 0 [反思] 一开始记录答案的时候,记录错…
题意: 给定N个字符串,寻找最长的公共字串,如果长度相同,则输出字典序最小的那个. 找其中一个字符串,枚举它的所有的字串,然后,逐个kmp比较.......相当暴力,可二分优化. #include <cstdio> #include <cmath> #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace…
http://acm.hdu.edu.cn/showproblem.php?pid=5510 Bazinga Problem Description   Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.For n given strings S1,S2,⋯,Sn, labelled from 1 to n, you should find the largest i (1≤i≤n) su…
http://blog.sina.com.cn/s/blog_74e20d8901010pwp.html我采用的是方法三. 注意:当长度相同时,取字典序最小的. #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> /* http://blog.sina.com.cn/s/blog_74e20d8901010pwp.html 我采用的是方法三. 注意:当…
[题目链接] http://poj.org/problem?id=3450 [题目大意] 求k个字符串的最长公共子串,如果有多个答案,则输出字典序最小的. [题解] 我们对第一个串的每一个后缀和其余所有串做kmp,取匹配最小值的最大值就是答案. [代码] #include <cstring> #include <cstdio> #include <algorithm> const int N=4050,M=210; using namespace std; int nx…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 思路: 一开始直接用KMP莽了发,超时了,后面发现如果前面的字符串被后面的字符串包含,那么我们就不需要用前面的字符串去比较了,把他标记掉就好了. 实现代码: #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> using namespace std; ][];…
Problem Description You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.   Input The first line of the input…
http://acm.hdu.edu.cn/showproblem.php?pid=5510 想了很久队友叫我用ufs + kmp暴力过去了. fa[x] = y表示x是y的子串,所以只有fa[x] == x才需要kmp一次. 那么这样的话,如果全部都不互为子串的话,复杂度还是爆咋的. #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4749 Problem Description   2013 is the 60 anniversary of Nanjing University of Science and Technology, and today happens to be the anniversary date. On this happy festival, school authority hopes that th…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5007 解题报告:输入一篇文章,从头开始,当遇到 “Apple”, “iPhone”, “iPod”, “iPad” 这几个字符串时,输出”MAI MAI MAI!“,当遇到"Sony"时,输出“SONY DAFA IS GOOD!". 看题太渣,题目意思还有个每个单词最多只出现一次关键词.有了这个条件就简单了,只要分别对每个单词进行五次KMP,匹配到了就输出对应的解释. #inc…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5763 Another Meaning Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 问题描述 As is known to all, in many cases, a word has two meanings. Such as "hehe", which not only…