HDU 1238 Substrings
来源:互联网 发布:适合苹果电脑设计软件 编辑:程序博客网 时间:2024/05/21 10:11
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1238
Substrings
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7607 Accepted Submission(s): 3414
Problem Description
You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.
Input
The first line of the input file contains a single integer t (1 <= t <= 10), the number of test cases, followed by the input data for each test case. The first line of each test case contains a single integer n (1 <= n <= 100), the number of given strings, followed by n lines, each representing one string of minimum length 1 and maximum length 100. There is no extra white space before and after a string.
Output
There should be one line per test case containing the length of the largest string found.
Sample Input
23ABCDBCDFFBRCD2roseorchid
Sample Output
22
枚举暴搜
下面是AC的代码
#include <stdio.h>#include <string.h>int yuan(char c){ if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return 1; return 0;}int main(){ int len,i; char s[100000]; while(~scanf("%s",s) && strcmp(s,"end")) { int flag = 1; len = strlen(s); for(i = 0; i<len; i++) { if(yuan(s[i])) break; } if(i>=len) flag = 0; for(i = 1; i<len; i++) { if(!flag) break; if(s[i] == s[i-1]) { if(s[i]=='e' || s[i] == 'o') continue; flag = 0; break; } } for(i = 2; i<len; i++) { if(!flag) break; if(yuan(s[i]) && yuan(s[i-1]) && yuan(s[i-2])) flag = 0; else if(!yuan(s[i]) && !yuan(s[i-1]) && !yuan(s[i-2])) flag = 0; } if(flag) printf("<%s> is acceptable.\n",s); else printf("<%s> is not acceptable.\n",s); } return 0;}
0 0
- hdu-1238 Substrings
- HDU 1238 Substrings
- HDU 1238 ( Substrings )
- Hdu 1238 Substrings
- hdu 1238 Substrings
- hdu 1238 Substrings
- HDU 1238 Substrings
- hdu 1238 Substrings
- HDU 1238 Substrings
- hdu 1238 Substrings(KMP)
- hdu 1238 Substrings
- hdu 1238 Substrings
- hdu 1238 Substrings
- HDU 1238 Substrings
- HDU 1238 Substrings
- HDU 1238 Substrings
- HDU 1238 Substrings
- hdu 1238 Substrings
- 「转 MyArrow 」Linux Wireless架构总结
- Android性能优化典范
- SpringMVC使用@ResponseBody
- java内存溢出和内存泄露
- jstring 转换为 char *
- HDU 1238 Substrings
- python gevent使用-最简单把同步程序变成异步程序
- hdu-1698
- NGUI 点击按钮切换背景
- 工程在导入lib的时候出错 导入失败
- 如何编写js弹出确认删除的提示信息
- xampp在linux下无法使用mysql命令
- 求0x5f3759df的数学原理
- 仿照Launcher的Workspace实现左右滑动切换