比赛 |
20120330 |
评测结果 |
AAAAAAAAAA |
题目名称 |
字符串子串 |
最终得分 |
100 |
用户昵称 |
TBK |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2012-03-30 22:18:48 |
显示代码纯文本
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cmath>
- #include <cstring>
- #include <string>
- #include <iomanip>
- #include <vector>
- #include <set>
- #include <algorithm>
- #define MAXN 0x7fffffff
- using namespace std;
- int a,b,c,d,r[10],l=0;
- char ch[8][1000];
- struct fun
- {
- char cha[1000];
- }f[40321];
- bool bo[10];
- int cmp ( const void *a , const void *b )
- {
- struct fun *c = (struct fun *)a;
- struct fun *d = (struct fun *)b;
- return strcmp(c->cha,d->cha);
- }
- void DFS(int k)
- {
- int i,j;
- if (k==a)
- {
- d=0;
- for (i=0;i<a;i++)
- for (j=0;j<strlen(ch[r[i]]);j++)
- {
- f[l].cha[d]=ch[r[i]][j];
- d++;
- }
- l++;
- }
- for (i=0;i<a;i++)
- if (bo[i]==false)
- {
- r[k]=i;
- bo[i]=true;
- DFS(k+1);
- bo[i]=false;
- }
- }
- int main(void)
- {
- freopen("substring.in","r",stdin);
- freopen("substring.out","w",stdout);
- scanf("%d",&a);
- for (b=0;b<a;b++) cin>>ch[b];
- DFS(0);
- qsort(f,l,sizeof(fun),cmp);
- cout<<f[0].cha;
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
-