How ABC386F
  • 板块学术版
  • 楼主sjh0626
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/12/28 21:58
  • 上次更新2024/12/29 11:01:32
查看原帖
How ABC386F
1129497
sjh0626楼主2024/12/28 21:58

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;
}
2024/12/28 21:58
加载中...