POJ 3080 Blue Jeans
来源:互联网 发布:java 动态方法 编辑:程序博客网 时间:2024/05/01 07:56
这题绝对是被坑的滴血,我真想对网上某某人说,去你大爷的。
这题的思路挺简单,本来我以为要用的什么高深的算法,可是听别人说,直接暴力就可以解决,于是就做了。本来很快写好代码,可是语句代码坑了我好长好长时间。
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<stack>#include<queue>using namespace std;char dna[11][65];char ans[65];int m;void cpy(char *s1,char *s2,int id,int len){ int a=id+len,top=0; for(int i=0;i<65;i++)//就这里,把我坑的苦不堪言,一开始我听别人说可以memset(s2,0,sizeof(s2))来初始化,
//可是后面就出事了,查错误,查了老半天。 s2[i]='\0'; for(int i=id;i<a;i++) s2[top++]=s1[i];}void solve(){ char temp[65]="Z"; for(int i=3;i<=60;i++) { int len=60-i; for(int j=0;j<=len;j++) { cpy(dna[0],ans,j,i); bool isok=false; for(int k=1;k<m;k++) { if(strstr(dna[k],ans)==NULL) { isok=true; break; } } if(isok) continue; //printf("1 ans=%s\n",ans); int len1=strlen(temp); int len2=strlen(ans); if(len1<len2) strcpy(temp,ans); else if((len1==len2)&&strcmp(temp,ans)>0) strcpy(temp,ans); //printf("temp=%s\n",temp); } } if(temp[0]!='Z') printf("%s\n",temp); else printf("no significant commonalities\n");}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d",&m); memset(dna,0,sizeof(dna)); for(int i=0;i<m;i++) scanf("%s",dna[i]); solve(); } 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
- uva 699 The Falling Leaves (二叉树)
- 学术休假----求二次方程的根
- three.js 源码注释(八十七)extras/FontUtils.js
- linux查找包装grep脚本
- OpenCV学习篇之二 播放视频
- POJ 3080 Blue Jeans
- banner图片轮转(利用jquery)
- 工作纪要---解决统计差别问题
- iOS-target/action模式,delegate模式
- C++——宏观把控
- 冬令营第一阶段周报--罗双
- LeetCode[Math]: Sqrt(x)
- Junit的各种断言
- 人民日报读书笔记-2015年1月份 国企改革 + 京津冀