外站题(NKOJ)TLE求优化
  • 板块学术版
  • 楼主uncle_steve
  • 当前回复7
  • 已保存回复7
  • 发布时间2024/11/18 20:08
  • 上次更新2024/11/18 21:51:02
查看原帖
外站题(NKOJ)TLE求优化
1268907
uncle_steve楼主2024/11/18 20:08

题面:https://oj.nks-oi.top/d/EAGER/p/T1004?tid=673abbf16c69eeaa9addd708

我的TLE代码(60pts):

#include<bits/stdc++.h>
using namespace std;
string s,t;
bool bj(string a,string b){
	for(int i=0;i<a.length();i++){
		if(a[i]=='?'||b[i]=='?') continue;
		else if(a[i]==b[i]) continue;
		else return false;
	}
	return true;
}
int main()
{
	cin>>s>>t;
	int tlen=t.length();
	if(bj(s.substr(s.length()-tlen,tlen),t)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	for(int x=1;x<=tlen;x++){
		string c=s.substr(0,x)+s.substr(s.length()-(tlen-x),tlen-x);
		if(bj(c,t)) printf("Yes\n");
		else printf("No\n");
	}
	
	return 0;
}

有dalao帮忙吗?帮助必关。

2024/11/18 20:08
加载中...