#include<iostream>
#include<string>
using namespace std;
int main()
{
string str1;
string str2;
while (cin >> str1 >> str2)
{
if (str1.size() < str2.size())
swap(str1, str2);
int length1 = str1.size();
int length2 = str2.size();
if (length1 == 0 || length2 == 0)
{
cout << 0 << endl;
return 0;
}
int maxsize = 0;
int k = 0;
for (int i = 0; i < length1; ++i)
{
for (int j = 0; j < length2;++j)
{
int flag = 0;
k = i;
int count = 0;
while (k < length1 && j < length2 &&str1[k] == str2[j] || str1[k] == str2[j] - 32 || str1[k] == str2[j] + 32)
{
++k;
++j;
flag = 1;
++count;
}
k = i;
if (count > maxsize)
{
maxsize = count;
}
if (flag == 1)
--j;
}
}
cout << maxsize << endl;
maxsize = 0;
}
return 0;
}
このコードを記述するのに長い時間、1の複素空間のために言っているが、テストケースオフあまりにも多くの牛の詳細は見ることができない、私はあまりにもハード。
コード分析のために:
レッツは、常に最長の文字列が保存されているSTR1
特殊なケースが決定しますがケースを使用していない牛の乗客が同じように見えます
ので、長い文字列が短い文字列を行う外部のサイクリング条件を、行う、ダブルループが続きますサイクル条件