poj 3080 Blue Jeans (串)
2017-01-20 19:35
351 查看
#include <iostream> #include <string> #define MAXN 60 /* 暑假看的,没做记录,当时用的kmp,现在复习下stl 当时做的不是这个(stl没过)现在差点忘了,复习下正好 顺便提下,npos比跟.size()比好得多,不必考虑边界问题 可以用于find,发到博客用于备忘 */ using namespace std; int main() { int t; cin>>t; while(t--) { int n; cin>>n; string str[15]; for(int i=0;i<n;i++) cin>>str[i]; string res=""; for(int i=3;i<=MAXN;i++) { for(int j=0;j<=MAXN-i;j++) { string tmp=str[0].substr(j,i); bool flag=true; for(int k=1;k<n;k++) if(str[k].find(tmp)==string::npos) { flag=false; break; } if(flag&&res.size()<tmp.size()) res=tmp; else if(flag&&res.size()==tmp.size()&&res>tmp) res=tmp; } } if(res == "") cout <<"no significant commonalities" << endl; else cout << res << endl; } return 0; }
相关文章推荐
- POJ 3080 Blue Jeans (求最长公共字符串)
- poj 3080 Blue Jeans
- Blue Jeans - POJ 3080(多串的共同子串)
- poj 3080 Blue Jeans (多串最长公共子串 暴力)
- POJ - 3080 Blue Jeans
- POJ 题目3080 Blue Jeans(KMP+暴力)
- poj 3080 Blue Jeans 字符串,暴力
- poj 3080 Blue Jeans(KMP)
- POJ 3080 Blue jeans
- poj 3080 Blue Jeans
- [poj 3080]Blue Jeans[暴力枚举子串]
- POJ 3080 Blue Jeans (KMP+暴力枚举)【模板】
- poj 3080 Blue jeans
- poj 3080 Blue Jeans(最长公共子串)
- poj_3080 Blue Jeans(暴力+字符串)
- POJ - 3080 - Blue Jeans
- POJ 3080 Blue Jeans
- poj-3080 Blue Jeans
- poj3080 Blue Jeans
- POJ 3080 Blue Jeans Trie后缀树解法