poj 3080 Blue Jeans
来源:互联网 发布:手机上能装修淘宝店铺 编辑:程序博客网 时间:2024/06/04 17:49
最长公子列。。 第一反应是dp。。
然而有那么多。。
有人说用后缀数组。。不会。。
但是discuss说kmp+暴力可以玩。 于是真的好水这道题。。
居然0ms
#include<cstdio>#include<cstring>#include<algorithm>#include<string>#include<set>#include<iostream>using namespace std;char a[11][70];char test[70];int next[70];set<string>ans;int main(){ int T; cin>>T; while(T--) { int n; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } ans.clear(); int len=strlen(a[0]); for(int i=len;i>=1;i--) { if(i<3) { cout<<"no significant commonalities"<<endl; break; } for(int j=0;j<=len-i;j++) { char ch=a[0][j+i]; a[0][j+i]='\0'; strcpy(test,a[0]+j); a[0][j+i]=ch; next[0]=-1; int k=0; int p=next[0]; while(k<i)//build next; { if(p==-1||test[k]==test[p]) { k++; p++; next[k]=p; } else { p=next[p]; } } int flag=0; for(int who=1;who<n;who++) { k=0; p=0; int ok=0; while(k<len) { if(p==-1||a[who][k]==test[p]) { p++; k++; } else { p=next[p]; } if(p==i) { ok=1; break; } } if(!ok) { flag=1; break; } } if(!flag) { ans.insert(test); } } if(!ans.empty()) { cout<<*ans.begin()<<endl; break; } } } return 0;}
0 0
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- Poj 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080-Blue Jeans
- Hibernate中的映射关系(二)
- macbook pro换固态硬盘ssd与移植mac os x系统
- 项目管理 hdoj 4858 (vector初学)
- 【LeetCode】LeetCode——第15题:3Sum
- Webview访问移动网络的两种方法
- poj 3080 Blue Jeans
- hive启动失败的小问题总结以及hive
- Leetcode Number of 1 Bits 191
- 欢迎使用CSDN-markdown编辑器
- Spring与Quartz的整合实现定时任务调度
- 练习题c++(一)
- java文件拷贝类
- 一分钟教你用Chrome的RSS来订阅博客
- 文本文件格式浅析以及转换