悬关全TLE
查看原帖
悬关全TLE
862592
__sunhy2012__楼主2025/1/23 16:57
#include<bits/stdc++.h>
using namespace std;

const long long INF = 1e5+10;
char str[INF];
long long f[INF], m;
bool yz(long long start, long long end);
int main(){
	std::ios_base::sync_with_stdio (false);
	std::cin.tie(nullptr);
	cin>>str;
	int lenght=strlen(str);
	long long yz1=0;
	for (long long i=0;i<lenght;++i){
		memset(f,0,sizeof(f));
		for (long long j=i;j<lenght;++j) {
			f[str[j]-'a']++;
			if (yz(i,j))
				yz1++;
		}
	}
	cout<<yz1;
	return 0;
}
bool yz(long long start, long long end){
	m=*max_element(f, f + 26);
	return m<=((end-start+1)/2);
}

验证码:6767

2025/1/23 16:57
加载中...