POJ 3450-Corporate Identity
来源:互联网 发布:组合软件 编辑:程序博客网 时间:2024/05/21 17:37
同上篇博客,把POJ3080的代码修改一下,暴力过去~
</pre><pre name="code" class="cpp">#include<string.h>#include<stdio.h>char str[11000][261],ss[11101],sss[11101];int next[11101],maxn=0,cnt=0,len;int panduan(int k){ int j=-1,i=0; next[0]=-1; int len1=strlen(str[k]); while(i<cnt) { if(j==-1||ss[i]==ss[j]) next[++i]=++j; else j=next[j]; } i=0,j=0; int ans=0; while(i<len1) { if(ss[j]==str[k][i]) { if(j==cnt-1) { ans++; j=next[j]; } else { i++; j++; } } else { if(j==-1) { i++; j++; } else j=next[j]; } if(ans==1) return 1; } if(ans) return 1; return 0;}int main(){ while(1) { int n; scanf("%d",&n); if(n==0) break; int tt; len=10010; for(int i=0; i<n; i++) { scanf("%s",str[i]); if(len>strlen(str[i])) { len=strlen(str[i]); tt=i; } } maxn=0; for(int i=0; i<strlen(str[tt]); i++) { for(int j=0; j<strlen(str[tt]); j++) { if(j-i<maxn)//当得到一个字符串符合条件,后面的字符串不比这个长就直接PASS。 continue; cnt=0; for(int k=i; k<=j; k++) ss[cnt++]=str[tt][k]; ss[cnt]='\0'; int f=0; for(int k=1; k<n; k++) { int t=panduan(k); if(!t) { f=1; break; } } if(f==0) { if(maxn<cnt) { strcpy(sss,ss); maxn=cnt; } if(maxn==cnt) { maxn=cnt; if(strcmp(sss,ss)>0) strcpy(sss,ss); } } } } if(maxn!=0) printf("%s\n",sss); else puts("IDENTITY LOST"); } return 0;}
0 0
- poj 3450 Corporate Identity
- POJ-3450-Corporate Identity
- POJ 3450 Corporate Identity
- POJ 3450 Corporate Identity
- poj 3450 Corporate Identity
- POJ 3450-Corporate Identity
- POJ 3450 Corporate Identity
- POJ-3450 Corporate Identity
- poj 3450 Corporate Identity
- POJ 3450 Corporate Identity
- poj 3450 Corporate Identity
- POJ 3450Corporate Identity
- POJ-3450-Corporate Identity(KMP)
- [KMP或者暴力]POJ 3450 Corporate Identity
- POJ 3450 Corporate Identity 暴力枚举+KMP
- POJ 3450Corporate Identity(暴力枚举+KMP)
- 【后缀数组】 POJ 3450 Corporate Identity
- POJ 3450 Corporate Identity KMP题解
- 苹果iOS 7后台机制解析
- NET:Checkboxlist,Dropdownlist 添加ToolTip说明
- activeMQ 资料
- 揭秘QQ 安全密码框的原理
- lnmp -一键安装完成信息
- POJ 3450-Corporate Identity
- Hadoop URL数据读取操作
- iOS操作系统的层次架构和相关服务
- Codeforces Round #FF (Div. 2/B)/Codeforces447B_ DZY Loves Strings(字符串处理)
- 创建表(先判断是否有表)
- 数字图像处理-空间域增强(三)(图像的算数与逻辑运算)
- robotium(下)
- Dos命令删除添加新服务
- 闭包相关的实例