#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct node
{
int lo,v;
}G[150005];
bool cmp(const node &a,const node &b)
{
if(a.v==b.v)
return a.lo<b.lo;
else
return a.v>b.v;
}
char str1[150050],str2[150050];
int main()
{
int n,p;
while(~scanf("%d%d",&n,&p)&&(n+p))
{
scanf("%s",str1);
scanf("%s",str2);
int t=0,res=0;
G[0].lo=0,G[0].v=0;
for(int i=1;i<=n;i++)
{
if(str1[i-1]!=str2[i-1])
t++;
G[i].v=100*t-i*p;
G[i].lo=i;
}
sort(G,G+1+n,cmp);
int lo=G[0].lo;
for(int i=1;i<=n;i++)
{
if(lo<G[i].lo)
res=max(res,G[i].lo-lo);
else
lo=G[i].lo;
}
if(res)
printf("%d\n",res);
else
printf("No solution.\n");
}
}
LA 3716
最新推荐文章于 2024-04-05 10:56:11 发布