HDOJ 5510-Bazinga【模拟】
来源:互联网 发布:网络买大麻暗语 编辑:程序博客网 时间:2024/06/04 21:16
Bazinga
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1468 Accepted Submission(s): 457
Problem Description
Ladies and gentlemen, please sit up straight.
Don't tilt your head. I'm serious.
Forn given strings S1,S2,⋯,Sn , labelled from 1 to n , you should find the largest i (1≤i≤n) such that there exists an integer j (1≤j<i) and Sj is not a substring of Si .
A substring of a stringSi is another string that occurs in Si . For example, ``ruiz" is a substring of ``ruizhang", and ``rzhang" is not a substring of ``ruizhang".
Don't tilt your head. I'm serious.
For
A substring of a string
Input
The first line contains an integer t (1≤t≤50) which is the number of test cases.
For each test case, the first line is the positive integern (1≤n≤500) 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 than2000 letters.
For each test case, the first line is the positive integer
All strings are given in lower-case letters and strings are no longer than
Output
For each test case, output the largest label you get. If it does not exist, output−1 .
Sample Input
45ababczabcabcdzabcd4youlovinyouaboutlovinyouallaboutlovinyou5dedefabcdabcdeabcdef3abaccc
Sample Output
Case #1: 4Case #2: -1Case #3: 4Case #4: 3
Source
2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
解题思路:
就是找到一个最大的下标字符串,上面的字符串不是这一串的字串。
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char map[2000][2000];int main(){int T;int yy=0;scanf("%d",&T);while(T--){int n,i,j,k;scanf("%d",&n);for(i=1;i<=n;i++){scanf("%s",map[i]);}int ans=-1;for(i=n;i>1;i--){if(!strstr(map[i],map[i-1])){ans=max(ans,i);for(j=i-1,k=i+1;k<=n;k++){if(!strstr(map[k],map[j]))ans=max(ans,k);}}}printf("Case #%d: %d\n",++yy,ans);}return 0;}
0 0
- HDOJ 5510-Bazinga【模拟】
- HDOJ--5510--Bazinga
- hdoj 5510 Bazinga
- hdoj 5510 Bazinga 【不要想太多。。。 strstr】
- HDOJ 题目5510 Bazinga(瞎搞)
- HDOJ 5510 Bazinga 【2015沈阳现场赛】字符串
- HDOJ 4126 Bazinga (字符串预处理)
- HDU 5510 Bazinga
- HDU 5510 Bazinga(思维)
- hdu 5510 -Bazinga(kmp)
- hdu 5510 Bazinga(kmp)
- HDU 5510 Bazinga 【strstr】
- HDU-5510 Bazinga
- HDU 5510 Bazinga 【kmp】
- HDU 5510 Bazinga(KMP)
- HDU 5510 Bazinga(kmp)
- Bazinga
- HDU 5510 Bazinga(模拟双向链表或kmp或AC自动机)
- Eclipse和Tomcat联合进行网络编程的环境搭建
- ListView优化总结
- InputStream String与byte数组之间的互转
- 摄像头立体成像资料记录--SLAM和MonoSLAM
- linux下如何配置TCP参数设置详解
- HDOJ 5510-Bazinga【模拟】
- 交叉编译freetype 2.6.2,个人实际操作
- ios版本更新
- mongodb地理信息应用
- mac 对手机抓包命令.
- 可以彻底从你的mac上卸载掉node.js
- Java——private,protected,public
- HDU 1693 Eat the Trees 插头DP
- Oracle 禁止操作系统认证登录