hdu2328(后缀数组 + 二分)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2328 题意: 求 n 个串的字典序最小的最长公共子串 思路: 本题中单个字符串长度不超过 200, 可以暴力枚举一个字符串的所有前缀, 然后用kmp去匹配其他字符串. 我这里是用后缀数组写的. 类似 http://www.cnblogs.com/geloutingyu/p/7450580.html 不过本题是有 n 个字符串, 不能直接暴力判断. 不难想到这里可以直接二分答案长度, 不过 check 函数比较难想到, 具体看代码 代码: 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #define rank Rank 5 using namespace std; 6 7 const int MAXN = 1e6 + 10; 8 int sol; 9 char str[MAXN]; 10 int SA[MAXN], rank[MAXN], height[MAXN], sum[MAXN], tp[MAXN], vis[MAXN], tag[(int)(4e3 + 10)]; 11 12 bool cmp(int *f, int x, int y, int w){ 13 return f[x] == f