比赛 NOIP模拟赛1 评测结果 AAAAAAAAAA
题目名称 叉叉 最终得分 100
用户昵称 BFZD 运行时间 0.067 s
代码语言 C++ 内存使用 0.12 MiB
提交时间 2018-02-08 20:50:41
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=1000;
int a[maxn],b[30][30];
int cnt,len,ans;
char s[100000+10];
int main()
{
	freopen("xxxx.in","r",stdin);
	freopen("xxxx.out","w",stdout);
	scanf("%s",s);
	len=strlen(s);
	for(int i=0; i<len; i++)
	{
		int tmp=s[i]-'a';
		if(!a[tmp])
		{
			for(int j=0; j<26; j++)
			{
				if(a[j] && j!=tmp)
				 b[j][tmp]=1;
			}
			a[tmp]=1;
		}
		else
		{
			for(int j=0; j<26; j++)
			{
				ans+=b[tmp][j];
				b[tmp][j]=0;
			}
			for(int j=0; j<26; j++)
			{
				b[j][tmp]=0;
			}
			a[tmp]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}