非众数 WA on #6,#7,#8,#9,#10 求条
  • 板块学术版
  • 楼主yaodiguoan
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/4/19 21:11
  • 上次更新2024/4/20 07:10:27
查看原帖
非众数 WA on #6,#7,#8,#9,#10 求条
1023793
yaodiguoan楼主2024/4/19 21:11
#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define int __int128
#define hh putchar('\n')
#define kg putchar(' ')
namespace quickread{
	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<<3)+(x<<1)+ch-'0';ch=getchar();}
		return x*f;
	}
	inline void write(int x){
	    if(x<0){putchar('-');x=-x;}
	    if(x>9)write(x/10);
	    putchar(x%10+'0');
	}
}
using namespace quickread;
const int N=1e6+10;
int n,cnt[30];
set<string>st;
string s;
signed main(){
//	ios::sync_with_stdio(0);
//	cin.tie();cout.tie();
	cin>>s;
	n=s.length();
	s='0'+s;
	for(int len=2;len<=n;len++){
		for(int l=1;l+len-1<=n;l++){
			int r=l+len-1;
			memset(cnt,0,sizeof(cnt));
			for(int k=l;k<=r;k++) cnt[s[k]-'a'+1]++;
			bool flag=0;
			for(int k=1;k<=26;k++)
				if(cnt[k]>len/2){
					flag=1;
					break;
				}
			if(!flag) st.insert(s.substr(l,len));
		}
	}
	cout<<st.size();
	return 0;
}
2024/4/19 21:11
加载中...