CSPS2023T2大小样例都过0分求助
  • 板块学术版
  • 楼主ANDYlele
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/10/21 20:50
  • 上次更新2023/11/2 12:08:59
查看原帖
CSPS2023T2大小样例都过0分求助
997212
ANDYlele楼主2023/10/21 20:50
#include<iostream>
#include<cstdio>
#include<fstream>
using namespace std;
const int maxn=1e2+3;
const int maxm=1e4+7;
int n,ans,ch[maxm][maxn];string a;
int main()
{
//	freopen("game.in","r",stdin);
//	freopen("game.out","w",stdout);
	cin>>n>>a;
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)ch[i][a[j]-'a']++;
	for(int i=0;i<n;i++)
		for(int j=i;j<n;j++)
		{
			bool f=0;
			for(int k=0;k<=25;k++)
			{
				int t;
				if(i>0)t=ch[j][k]-ch[i-1][k];
				else t=ch[j][k];
				if(t&1)
				{
					f=1;
					break;
				}
			}
			ans=(f?ans:ans+1);
		}
	cout<<ans;
	return 0;
}
//目标50pts
2023/10/21 20:50
加载中...