Substrings
Problem DescriptionYou 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.
InputThe 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.
OutputThere should be one line per test case containing the length of the largest string found.
Sample Input
- 23ABCDBCDFFBRCD2roseorchid
Sample Output
- 22
- #include#include#includeint getmin(char str[][110], int n) {
- int min = INT_MAX,
- a;
- int i;
- for (i = 0; istrlen(str[i])) {
- min = strlen(str[i]);
- a = i;
- }
- }
- return a;
- }
- int main() {
- char s1[110],
- s2[110];
- char str[110][110];
- int t,
- n,
- min,
- len,
- max;
- int i,
- j,
- k;
- scanf("%d", &t);
- while (t--) {
- scanf("%d", &n);
- for (i = 0; imax && flag == 1) max = len1;
- flag = 1;
- }
- }
- printf("%d\n", max);
- }
- return 0;
- }
就爱阅读 www.92to.com 网友整理上传, 为您提供最全的知识大全, 期待您的分享,转载请注明出处。
来源: http://www.92to.com/bangong/2017/03-08/18341982.html