[poj 3450]Corporate Identity[暴力枚举子串]
来源:互联网 发布:mysql use index用法 编辑:程序博客网 时间:2024/05/16 08:04
题意:
和poj 3080相同.
同样是暴力.
又是循环边界的小毛病...
#include <cstring>#include <cstdio>//372K110MSconst int R = 4005;const int C = 205;char s[R][C];char t[C],ans[C];int n;int main(){ while(scanf("%d",&n)==1 && n) { for(int i=0;i<n;i++) scanf("%s",s[i]); int c = strlen(s[0]); bool next_id,get_len,get = false; for(int len=1;len<=c;len++) { get_len = false; for(int id=0;id<=c-len;id++) { strncpy(t,&s[0][id],len); t[len] = '\0'; next_id = false; for(int i=1;i<n;i++) { if(!strstr(s[i],t)) { next_id = true; break; } } if(!next_id) { if(!get) get = true; if(!get_len) { get_len = true; strcpy(ans,t); } else if(strcmp(t,ans)<0) strcpy(ans,t); } } if(!get_len) break; } printf("%s\n",get?ans:"IDENTITY LOST"); }}
- [poj 3450]Corporate Identity[暴力枚举子串]
- POJ 3450 Corporate Identity 暴力枚举+KMP
- POJ 3450Corporate Identity(暴力枚举+KMP)
- [KMP或者暴力]POJ 3450 Corporate Identity
- poj 3450 Corporate Identity 【暴力KMP】
- 【poj 3450 Corporate Identity 】 KMP(暴力)
- Corporate Identity (KMP+暴力枚举)
- POJ 3450--Corporate Identity【KMP && 枚举】
- poj 3450 Corporate Identity (KMP+最长公共子串)
- poj 3450 Corporate Identity 【KMP】【求公共子串】
- 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
- 这一回面临的是烂摊子接受一个有难度的挑战
- javascript书籍推荐
- filter知识
- 个人保存,以免将来找不到了!别举报啊!
- XPATH表达式
- [poj 3450]Corporate Identity[暴力枚举子串]
- Linux 下串口编程入门
- 题目1354:和为S的连续正数序列-九度
- nginx+keepalived高可用性负载均衡
- 进程
- 呃呃呃
- awk+sed+sort常用命令收集
- NGINX 的301 重定向
- 进程(二)