博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1238 Substrings(求公共正反向连续子串)
阅读量:4139 次
发布时间:2019-05-25

本文共 1657 字,大约阅读时间需要 5 分钟。

Substrings

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8504 Accepted Submission(s): 3931
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
Author
Asia 2002, Tehran (Iran), Preliminary
//优化 #include 
#include
#include
#include
using namespace std;const int N=100+10;int n,id,re,ilen;char c[N][N];int len[N];int main(){ int t,i,small,j,k,z,zz; bool ok; scanf("%d",&t); while(t--){ re=0; small=N; scanf("%d",&n); for(i=0;i
0;i--){ //枚举子串长度 for(j=0;re==0&&j+i-1
=0;z--) { //从右开始 for(zz=0;zz
#include
#include
#include
#include
using namespace std;const int N=100+10;int n,id,re,ilen,rlen;char c[N][N];int len[N];int main(){ int t,i,small,j,k,z,zz; bool ok; scanf("%d",&t); while(t--){ re=0; rlen=0; small=N; scanf("%d",&n); for(i=0;i
0;j--) { //子串的长度 for(k=0;k
=0;z--){ //从右开始 for(zz=0;zz

转载地址:http://bfmvi.baihongyu.com/

你可能感兴趣的文章
以亲身感受浅谈程序的注释和一个bug的代价(单位:RMB)
查看>>
当printf("-")遇上fork() ---某公司招聘笔试题目
查看>>
谢孟媛老师英语音标发音01(附我备注)
查看>>
谢孟媛老师英语音标发音02(附我备注)
查看>>
如何用C语言判断ip地址是否合法? (用inet_addr有问题)
查看>>
《随遇而安》 孟非
查看>>
如何引用另外一个文件中的串, 顺便说说void print();和(void)print();的区别
查看>>
今天第一次面试别人, 大概聊了近30分钟
查看>>
我经历的那些骗局(要承认, 骗子智商比我们高)
查看>>
C语言一个文件中的函数能直接调用另外一个文件中的静态函数吗? (某公司校园招聘面试试题)
查看>>
有“空洞”的文件的C代码实现
查看>>
简单详解:x^6+4x^4+2x^3+x+1 至少要需要多少次乘法? (某公司实习生招聘笔试试题)
查看>>
int a1=x+y-z; int a2=x-z+y; a1和a2的值一定相等吗? (某公司实习生招聘笔试试题)
查看>>
聊聊这个与代码优化有关的选择题 (某公司实习生招聘笔试试题)
查看>>
Windows环境下利用“共享内存”实现进程间通信的C/C++代码---利用CreateFileMapping和MapViewOfFile
查看>>
再谈IPC之共享内存 (某公司实习生招聘笔试试题)
查看>>
又见组合数, 好亲切! (某公司实习生招聘笔试试题)
查看>>
数据库表删除之drop table xxx (某公司实习生招聘笔试试题)
查看>>
任务调度时间 (某公司实习生招聘笔试试题)
查看>>
国庆期间遇到两个诈骗团伙
查看>>