POJ-3080 Blue Jeans(纯暴力)
来源:互联网 发布:java开发框架 编辑:程序博客网 时间:2024/06/05 20:07
这道题但是真的想了太久,一直纳闷kmp怎么跑n个字符,
后来查了题解才知道原来无脑暴力就能过,真是醉了。
大致题意和思路:
找出n个串中最长的公共串,并且要求字典序最大
直接枚举第一串的所有子串,然后与后面的所有串进行比较即可
拓展:<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">strstr(str1,str2);</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;"> 函数用于判断字符串str2是否是str1的子串。如果是,则该函数返回str2在str1中首次出现的地址;否则,返回NULL。</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: arial, 宋体, sans-serif, tahoma, 'Microsoft YaHei'; font-size: 14px; line-height: 24px;"><pre name="code" class="cpp">#include<stdio.h>#include<string.h>#include<stdlib.h>#include<limits.h>#include<algorithm>using namespace std;int n,m;char a[15][65];char b[65],c[65];int main(){int T,i,j;scanf("%d",&T);while(T--){memset(c,'\0',sizeof(c));scanf("%d",&n);for(i=1;i<=n;i++)scanf("%s",a[i]);for(i=1;i<=60;i++){int flag=0;for(j=0;j<=60-i;j++){int len=0;int check=1;for(int k=j;;k++){b[len++]=a[1][k];if(len==i)break;}b[len]='\0';for(int k=2;k<=n;k++){if(!strstr(a[k],b)){check=0;break;}}if(check){flag=1;if(strlen(c)<strlen(b))strcpy(c,b);if(strcmp(c,b)>0)strcpy(c,b);}}if(!flag)break;}if(strlen(c)<3)printf("no significant commonalities\n");elseprintf("%s\n",c);}}
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(KMP+暴力)
- POJ -3080 Blue Jeans(暴力就可以了)
- POJ 3080 Blue Jeans(暴力枚举+kmp)
- POJ-3080---Blue Jeans (strstr函数暴力求解)
- POJ 3080 Blue Jeans (KMP+暴力枚举)【模板】
- POJ 3080 Blue Jeans(暴力模拟+stl)
- [KMP或者暴力]POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans 暴力枚举+KMP
- POJ 3080 Blue Jeans KMP+暴力
- poj 3080 Blue Jeans (kmp暴力)
- POJ 3080 Blue Jeans (KMP || 暴力)
- poj-3080-Blue Jeans-串-暴力
- hdoj 1969 Pie 【二分】
- SCI
- Xcode是如何诞生的?
- A*算法 cocos2dx 8数码
- jenkins+maven+svn+tomcat之快速部署初探(docker篇)
- POJ-3080 Blue Jeans(纯暴力)
- 常见的排序算法
- POJ 1050 To the Max
- PCB的初步认识
- CodeIgniter框架源码笔记(8)——性能调试:基准测试类Benchmark.php
- 开博客那么久了,发一篇博客先
- nyoj 12 喷水装置(二)
- 背包九讲总结
- 利用 ViewPage 实现类似TabHost的功能,仅点击才可切换屏