hdu 5510 Bazinga(暴力)
Ladies and gentlemen, please sit up straight.
Don't tilt your head. I'm serious.

For n given strings S1,S2,⋯,Sn, labelled from to n, you should find the largest i (≤i≤n) such that there exists an integer j (≤j<i) and Sj is not a substring of Si. A substring of a string Si is another string that occurs in Si. For example, ``ruiz" is a substring of ``ruizhang", and ``rzhang" is not a substring of ``ruizhang".
The first line contains an integer t (≤t≤) which is the number of test cases.
For each test case, the first line is the positive integer n (≤n≤) and in the following n lines list are the strings S1,S2,⋯,Sn.
All strings are given in lower-case letters and strings are no longer than letters.
For each test case, output the largest label you get. If it does not exist, output −.
ab
abc
zabc
abcd
zabcd you
lovinyou
aboutlovinyou
allaboutlovinyou de
def
abcd
abcde
abcdef a
ba
ccc
Case #:
Case #: -
Case #:
Case #:
题意:你需要找到一个最大的i使得,存在一个在他前面的字符串不是他的子串
直接暴力也能过,这是区域赛吗?
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 506
#define M 2006
#define inf 1e12
int n;
char s[N][M];
int vis[N];
int main()
{
int t;
int ac=;
scanf("%d",&t);
while(t--){
memset(vis,,sizeof(vis));
scanf("%d",&n);
int ans=-;
for(int i=;i<=n;i++){
scanf("%s",s[i]);
for(int j=i-;j>=;j--){
if(vis[j]) continue;
if(strstr(s[i],s[j])==) ans=i;
else vis[j]=;
}
} printf("Case #%d: ",++ac); if(ans==-){
printf("-1\n");
}else{
printf("%d\n",ans);
}
}
return ;
}
hdu 5510 Bazinga(暴力)的更多相关文章
- HDU 5510 Bazinga 暴力匹配加剪枝
Bazinga Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5510 ...
- hdu 5510 Bazinga(字符串kmp)
Bazinga Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- Bazinga HDU 5510 Bazinga(双指针)
Bazinga HDU 5510 Bazinga(双指针) 题链 解法:对于串i来说,如果串i是不符合的,那么代表串i之前的字符串都是i的子串,那么我们求一个新的i(定义为ti),如果i是ti 的子串 ...
- hdu 5510 Bazinga (KMP+暴力标记)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 思路: 一开始直接用KMP莽了发,超时了,后面发现如果前面的字符串被后面的字符串包含,那么我们就 ...
- hdu 5510 Bazinga
http://acm.hdu.edu.cn/showproblem.php?pid=5510 Problem Description: Ladies and gentlemen, please sit ...
- hdu 5510 Bazinga KMP+尺取法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 题意:至多50组数据,每组数据至多500个字符串,每个字符串的长度最长为2000.问最大的下标( ...
- 【HDU 5510 Bazinga】字符串
2015沈阳区域赛现场赛第2题 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 题意:给定一个由字符串组成的序列,一共n个元素,每个元素是一个不 ...
- hdu 5510 Bazinga (kmp+dfs剪枝) 2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: ...
- HDU 5510 Bazinga (2015沈阳现场赛,子串判断)
Bazinga Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
随机推荐
- android JNI调用 execlp函数
execlp()函数 execlp函数简单的来说就是C语言中执行系统命令的函数 execlp()会从PATH 环境变量所指的目录中查找符合参数file 的文件名, ...
- 算法(Algorithm)是什么?
我们用煎蛋来打个比方.煎蛋的一般步骤是: 1.>取煎锅. 2.>取油. ->我们有油吗? ****有,把油倒入煎锅. ****没有,我们要去买油吗? #########要买,出去买油 ...
- Raphaël—JavaScript Library
Raphaël-JavaScript Library What is it? Raphaël is a small JavaScript library that should simplify yo ...
- A Corrupt Mayor's Performance Art(线段树区间更新+位运算,颜色段种类)
A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 100000/100 ...
- UE是什么意思?用户体验设计师与UE设计是什么关系?
本文来自:http://blog.sina.com.cn/s/blog_a6bebb3f01015h47.html 什么是UE(UE——UE就是用户体验度) 你会发觉他的使用很人性化:功能强大但操作简 ...
- 【Heritrix基础教程之3】Heritrix的基本架构
Heritrix可分为四大模块: 1.控制器CrawlController 2.待处理的uri列表 Frontier 3.线程池 ToeThread 4.各个步骤的处理器 (1)Pre-fetch ...
- LDAP实例异常停止日志提示虚拟内存virtual memory不足
[05/Oct/2014:20:50:37 +0800] - ERROR<5135> - Resource Limit - conn=-1 op=-1 msgId=-1 - Memory ...
- for循环删除集合陷阱
首先看下面的代码: import java.util.LinkedList;import java.util.List; public class DeleteCollection { ...
- tomcat中的URL参数为中文,servlet接收后显示乱码
URL中参数的值为中文时,servlet接收后显示为乱码,如下图: 这时候需要修改tomcat的中的server.xml文件.该文件路径为 tomcat安装目录下的conf文件夹. 为修改前的se ...
- weblogic配置domain和删除domain
weblogic创建域的过程比较简单,但是在创建域之前一定要注意不能存在重名的domain. Domain简单定义为:是一个逻辑管理单元,Domain下面包含着weblogic应用服务器中的所有东西, ...