HDOJ-----5311---Hidden String---暴力
来源:互联网 发布:ubuntu ctrl alt t 编辑:程序博客网 时间:2024/05/21 21:02
Hidden String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1961 Accepted Submission(s): 731
Problem Description
Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a strings of length n . He wants to find three nonoverlapping substrings s[l1..r1] ,s[l2..r2] ,s[l3..r3] that:
1.1≤l1≤r1<l2≤r2<l3≤r3≤n
2. The concatenation ofs[l1..r1] ,s[l2..r2] ,s[l3..r3] is "anniversary".
1.
2. The concatenation of
Input
There are multiple test cases. The first line of input contains an integerT (1≤T≤100) , indicating the number of test cases. For each test case:
There's a line containing a strings (1≤|s|≤100) consisting of lowercase English letters.
There's a line containing a string
Output
For each test case, output "YES" (without the quotes) if Soda can find such thress substrings, otherwise output "NO" (without the quotes).
Sample Input
2annivddfdersewwefarynniversarya
Sample Output
YESNO
#include<cstdio>#include<iostream>#include<cstring>#define LL long longusing namespace std;char s[110], m[20] = "anniversary";bool solve(){int c = strlen(s+1);for(int i = 1; i <= 9; i++){//分为三段,i是一段,j-i是一段,11-j是一段for(int j = i+1; j <= 10; j++){int r = 1;while(r <= c && strncmp(m, s+r, i)) r++;//检查第一段是否满足if(r == c) continue;r += i;while(r <= c && strncmp(m+i, s+r, j-i)) r++;if(r == c) continue;r += j-i;while(r <= c && strncmp(m+j, s+r, 11-j)) r++;if(r <= c) return true; }}return false;}int main(){int t, n;cin >> t;while(t--){cin >> s+1;printf(solve() ? "YES\n" : "NO\n");}return 0;}
0 0
- HDOJ-----5311---Hidden String---暴力
- hdoj 5311 Hidden String 【KMP + 暴力】
- hdoj 5311 Hidden String (暴力枚举)
- HDOJ 5311-Hidden String【深搜】
- HDOJ 5311 Hidden String(枚举)
- hdoj 5311 Hidden String 【dfs】
- HDU 5311 Hidden String (优美的暴力)
- hdu 5311 Hidden String(dp+暴力dfs)
- hdoj 5311 Hidden String 【dfs(递归)】【周赛】
- HDOJ 5533-Hidden String
- 杭电5311-Hidden String(暴力列举)
- HDOJ 5311 Hidden String(DFS不错的题)
- HDU 5310 Hidden String(暴力枚举)
- hdoj--1034--Hidden String(dfs)
- HDU 5311:Hidden String
- HDU 5311 Hidden String
- hdu 5311 Hidden String
- Hidden String(5311)
- 机器学习斯坦福公开课学习笔记
- 头疼的算法与数据结构——红黑树
- 解决Could not find method android() for arguments问题
- Spring跨controller数据传输
- 垃圾收集器
- HDOJ-----5311---Hidden String---暴力
- 机器学习基石笔记(8)——Error Measure
- numpy矩阵的基础操作
- Objective-C 关联引用的实例 (59)
- JavaScript之树形结构数据(二)
- Wex5 模式4 震动插件
- 【算法作业3】LeetCode 169. Majority Element
- Linux下实用功能make的使用入门
- SWPU-ACM集训队周赛之个人赛(3-18)----题解