显示代码纯文本
#include <iostream>
#include <fstream>
#include <cstring>
#include<cstdio>
using namespace std;
char assemble[210][15];
string str;
int main() {
freopen("prefix.in","r",stdin);
freopen("prefix.out","w",stdout);
int count=0,Max=0;
while(cin>>assemble[count]&&assemble[count++][0]!='.');
str="";
string s;
while(cin>>s)
str+=s;
for(int i=0;i<str.length();i++)
{
for(int j=0;j<count;j++)
{
if(i+strlen(assemble[j])<=str.length())
{
bool judge=true;
for(int k=0;k<strlen(assemble[j]);k++)
if(str[i+k]!=assemble[j][k])
{
judge=false;break;
}
if(judge)
if(Max<i+strlen(assemble[j]))
Max=i+strlen(assemble[j]);
}
}
if(i+1>Max)
break;
}
cout<<Max;
return 0;
}