题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=4080 Description Dr. Ellie Arroway has established contact with an extraterrestrial civilization. However, all efforts to decode their messages have failed so far because, as luck would have it, the…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5853 Description Jong Hyok loves strings. One day he gives a problem to his friend you. He writes down n strings Pi in front of you, and asks m questions. For i-th question, there is a string Qi. We…
Rabbit's String Problem Description Long long ago, there lived a lot of rabbits in the forest. One day, the king of the rabbit kingdom got a mysterious string and he wanted to study this string. At first, he would divide this string into no more than…
题目链接 : https://www.acwing.com/problem/content/description/142/ Hash + 二分 #include <bits/stdc++.h> using namespace std; ; typedef unsigned long long ull; ; ull p[maxn],h[maxn]; int sa[maxn],rank[maxn],height[maxn]; char str[maxn]; int n ; ull get(int…
题意:找一个出现了m次的最长子串,以及这时的最右的位置. hash的话代码还是比较好写的,,但是时间比SA多很多.. #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; + ; typedef long long ll; ; ; char s[N]; int m,len,pw[N]; int H[N],pos; struct node { int id,hash…
Life Forms Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, eyebrows and the like. A few bear no human resemblance; these typically have ge…
题意:给你最多100个字符串,求最长的且是一半以上的字符串的公共子串,如果有多个,按字典序输出. 思路:先把各个串拼起来,中间加上一个之前未出现过的字符,然后求后缀.然后根据h数组和sa数组,求出最长的公共串. #include<stdio.h> #include<string.h> #include<algorithm> using std::sort; #define V 220000 int r[V],sa[V],h[V],a[V],b[V],X[V],Y[V];…
Musical Theme Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this representation of melodies ignores the…
Musical Theme Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this representation of melodies ignores the n…
题目链接:https://vjudge.net/problem/POJ-3294 Life Forms Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 16905 Accepted: 4970 Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial t…
Life Forms Problem's Link Mean: 给你n个串,让你找出出现次数大于n/2的最长公共子串.如果有多个,按字典序排列输出. analyse: 经典题. 直接二分判断答案. 判断答案p时,我们扫一遍height数组,如果height[i]<p时开辟一个新段. 判断时用set存储所在串编号,不仅起到去重的作用,而且也起到统计段长的作用. 也可以直接用字符串hash来做,也是先二分,然后O(n)判断,时间复杂度和后缀数组一样. Time complexity: O(N*log…