WA 18个点,打ABC打自闭了。
#include<bits/stdc++.h>
#define sjh0626s return
#define code 0
#define ll long long
using namespace std;
class FastIO{
public:
inline int read(){
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
FastIO &operator>>(int &x){
x=read();
return *this;
}
};
FastIO qin;
int k,l1,l2,i,cnt,l=0;
string s,t;
map<char,int>m;
int main(){
qin>>k;
cin>>s>>t;
if(s==t){
cout<<"Yes";
sjh0626s code;
}
l1=s.size(),l2=t.size();
if(abs(l1-l2)>k){
cout<<"No";
sjh0626s code;
}
--l1,--l2;
while(l<l1&&l<l2&&s[l]==t[l])l++;
while(l<l1&&l<l2&&s[l1]==t[l2])l1--,l2--;
cnt=l1-l+l2-l;
if(cnt<=k)cout<<"Yes";
else cout<<"No";
sjh0626s code;
}