题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510
找到一个最大i,使得前面的字符串有一个不是他的子串。
——队友告诉我strstr能过,不知为何用kmp T了两发……又好几天不写了…….
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <stack>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=2005;
int t,n,m,k;
int a[N],b[N];
char s[N][N];
int main()
{
scanf("%d",&t);
k=1;
while(t--)
{
memset(a,0,sizeof(a));
scanf("%d",&n);
m=-1;
for(int i=1; i<=n; i++)
{
scanf("%s",s[i]);
for(int j=i-1; j>=1; j--)
{
if(a[j])
continue;
if(strstr(s[i],s[j])==NULL)
m=i;
else
a[j]=1;
}
}
printf("Case #%d: %dn",k++,m);
}
}
最后
以上就是潇洒小虾米最近收集整理的关于HDU 5510 Bazinga(2015亚洲区沈阳站现场赛)的全部内容,更多相关HDU内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复