hdu 3553 Just a String (后缀数组) 题意:很简单,问一个字符串的第k大的子串是谁. 解题思路:后缀数组.先预处理一遍,把能算的都算出来.将后缀按sa排序,假如我们知道答案在那个区间范围内了(假设为[l,r]),那么我们算下这个区间内的lcp的最小值(设最小值的位置为mid,大小为x),如果x*(r-l+1)>=k,那么,答案就是这个区间的lcp的最小值的某一部分(具体是哪一部分,画个图稍微算下就出来了).如果x * ( r - l + 1 ) < k 那么我们分两种情况…
题目链接 Ashton appeared for a job interview and is asked the following question. Arrange all the distinct substrings of a given string in lexicographical order and concatenate them. Print the Kth character of the concatenated string. It is assured that…
题目链接 Problem Description Uncle Mao is a wonderful ACMER. One day he met an easy problem, but Uncle Mao was so lazy that he left the problem to you. I hope you can give him a solution.Given a string s, we define a substring that happens exactly k time…
题意:给定一个字符串,问你它有多少个子串恰好出现 k 次. 析:后缀数组,先把height 数组处理出来,然后每次取 k 个进行分析,假设取的是 i ~ i+k-1,那么就有重复的,一个是 i-1 ~ i+k-1,另一个是 i ~ i+k,但是这样就删多了,再加上 i - 1 ~ i+k,这样就OK了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #inclu…
                                                                                                  Facer’s string Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 1783   Accepted: 537 Description Minifacer was very happy these days because…
Rabbit's String Time Limit: 40000/20000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 288    Accepted Submission(s): 108 Problem Description Long long ago, there lived a lot of rabbits in the forest. One day, the…
最少出现K次我们可以用Height数组的lcp来得出,而恰好出现K次,我们只要除去最少出现K+1次的lcp即可. #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> using namespace std; + ; int t1[maxn], t2[maxn], c[maxn]; bool cmp(int* r, int a, int b, int l)…
[Codechef CHSTR] Chef and String Description 每次询问 \(S\) 的子串中,选出 \(k\) 个相同子串的方案有多少种. Solution 本题要求不是很高,\(O(n^2)\) 统计每个出现次数子串个数即可. 我因为一个lld WA了一晚上(猛然意识到要%d读入long long的时候,之前一直没有翻车的原因是开了全局,如果是局部又不初始化就瞬间gg了,然鹅这个错误本地查不出来) #include <bits/stdc++.h> using na…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5008 Description In this problem, you are given a string s and q queries. For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which one is…
题目 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…