Problem Description
  1. Ladies and gentlemen, please sit up straight.
  2. Don't tilt your head. I'm serious.

  1. For n given strings S1,S2,⋯,Sn, labelled from to n, you should find the largest i (≤in) such that there exists an integer j (≤j<i) and Sj is not a substring of Si.
  2.  
  3. 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".
 
Input
  1. The first line contains an integer t (≤t≤) which is the number of test cases.
  2. 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.
  3. All strings are given in lower-case letters and strings are no longer than letters.
 
Output
  1. For each test case, output the largest label you get. If it does not exist, output −.
 
Sample Input
  1.  
  2. ab
  3. abc
  4. zabc
  5. abcd
  6. zabcd
  7.  
  8. you
  9. lovinyou
  10. aboutlovinyou
  11. allaboutlovinyou
  12.  
  13. de
  14. def
  15. abcd
  16. abcde
  17. abcdef
  18.  
  19. a
  20. ba
  21. ccc
Sample Output
  1. Case #:
  2. Case #: -
  3. Case #:
  4. Case #:
 
Source
 

 题意:你需要找到一个最大的i使得,存在一个在他前面的字符串不是他的子串

直接暴力也能过,这是区域赛吗?

  1. #pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<iostream>
  3. #include<cstdio>
  4. #include<cstring>
  5. #include<cmath>
  6. #include<math.h>
  7. #include<algorithm>
  8. #include<queue>
  9. #include<set>
  10. #include<bitset>
  11. #include<map>
  12. #include<vector>
  13. #include<stdlib.h>
  14. #include <stack>
  15. using namespace std;
  16. #define PI acos(-1.0)
  17. #define max(a,b) (a) > (b) ? (a) : (b)
  18. #define min(a,b) (a) < (b) ? (a) : (b)
  19. #define ll long long
  20. #define eps 1e-10
  21. #define MOD 1000000007
  22. #define N 506
  23. #define M 2006
  24. #define inf 1e12
  25. int n;
  26. char s[N][M];
  27. int vis[N];
  28. int main()
  29. {
  30. int t;
  31. int ac=;
  32. scanf("%d",&t);
  33. while(t--){
  34. memset(vis,,sizeof(vis));
  35. scanf("%d",&n);
  36. int ans=-;
  37. for(int i=;i<=n;i++){
  38. scanf("%s",s[i]);
  39. for(int j=i-;j>=;j--){
  40. if(vis[j]) continue;
  41. if(strstr(s[i],s[j])==) ans=i;
  42. else vis[j]=;
  43. }
  44. }
  45.  
  46. printf("Case #%d: ",++ac);
  47.  
  48. if(ans==-){
  49. printf("-1\n");
  50. }else{
  51. printf("%d\n",ans);
  52. }
  53. }
  54. return ;
  55. }

hdu 5510 Bazinga(暴力)的更多相关文章

  1. HDU 5510 Bazinga 暴力匹配加剪枝

    Bazinga Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5510 ...

  2. hdu 5510 Bazinga(字符串kmp)

    Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  3. Bazinga HDU 5510 Bazinga(双指针)

    Bazinga HDU 5510 Bazinga(双指针) 题链 解法:对于串i来说,如果串i是不符合的,那么代表串i之前的字符串都是i的子串,那么我们求一个新的i(定义为ti),如果i是ti 的子串 ...

  4. hdu 5510 Bazinga (KMP+暴力标记)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 思路: 一开始直接用KMP莽了发,超时了,后面发现如果前面的字符串被后面的字符串包含,那么我们就 ...

  5. hdu 5510 Bazinga

    http://acm.hdu.edu.cn/showproblem.php?pid=5510 Problem Description: Ladies and gentlemen, please sit ...

  6. hdu 5510 Bazinga KMP+尺取法

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 题意:至多50组数据,每组数据至多500个字符串,每个字符串的长度最长为2000.问最大的下标( ...

  7. 【HDU 5510 Bazinga】字符串

    2015沈阳区域赛现场赛第2题 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 题意:给定一个由字符串组成的序列,一共n个元素,每个元素是一个不 ...

  8. hdu 5510 Bazinga (kmp+dfs剪枝) 2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)

    废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: ...

  9. HDU 5510 Bazinga (2015沈阳现场赛,子串判断)

    Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

随机推荐

  1. windows套接字相关函数

    windows套接字相关函数 作者:vpoet mail:vpoet_sir@163.com 我们学习TCP/IP协议无非是利用这些协议进行通信开发,然而如果让我们自己来直接根据协议规则和协议格式来进 ...

  2. 网易云课堂_C++开发入门到精通_章节6:多态

    课时33示例--为多态基类声明虚析构函数 微软校园招聘笔试题 #include <iostream> class Base { public: char Value() { return ...

  3. Radar Installation(贪心,可以转化为今年暑假不ac类型)

    Radar Installation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) ...

  4. 被「李笑来老师」拉黑之「JavaScript微博自动转发的脚本」

    故事的背景如下图,李笑来 老师于10月19日在 知乎Live 开设 一小时建立终生受用的阅读操作系统 的讲座,他老人家看到大家伙报名踊跃,便在微博上发起了一个 猜数量赢取iPhone7 的活动. 因为 ...

  5. Unique Binary Search Trees,Unique Binary Search Trees II

    Unique Binary Search Trees Total Accepted: 69271 Total Submissions: 191174 Difficulty: Medium Given  ...

  6. Git学习笔记:Git基础

    一.Git与其他版本控制系统的差别 Git 只关心文件数据的整体是否发生变化,而大多数其他系统则只关心文件内容的具体差异.这类系统每次记录有哪些文件作了更新,以及都更新了哪些行的什么内容.如下图,其他 ...

  7. 菜鸟的jQuery源码学习笔记(二)

    jQuery对象是使用构造函数和原型模式相结合的方式创建的.现在来看看jQuery的原型对象jQuery.prototype: jQuery.fn = jQuery.prototype = { //成 ...

  8. jquery-练习-折叠效果

    <!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml"> <head> < ...

  9. 修改ecshop模板体会

    在上一篇中给大家带来了ecshop的总体的框架.从总体上看ecshop,相信大家的思路应该很清楚.作为一个对开源项目修改者你来说,能对ecshop有个初步的了解就行了,下面我会给大家带来我在修改ecs ...

  10. 整理:GET与POST的区别

    1.根据HTTP规范,GET用于信息获取,而且应该是安全的和幂等的. (1).所谓安全的意味着该操作用于获取信息而非修改信息.换句话说,GET 请求一般不应产生副作用.就是说,它仅仅是获取资源信息,就 ...