/ Randle /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 1ms 316.0 KiB
#2 Wrong Answer 1ms 312.0 KiB
#3 Wrong Answer 1ms 320.0 KiB
#4 Wrong Answer 1ms 308.0 KiB
#5 Wrong Answer 1ms 320.0 KiB
#6 Wrong Answer 1ms 312.0 KiB
#7 Wrong Answer 1ms 312.0 KiB
#8 Wrong Answer 1ms 308.0 KiB
#9 Wrong Answer 1ms 324.0 KiB
#10 Wrong Answer 1ms 316.0 KiB

代码

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>

using namespace std;

const int maxn=1000010;

int n,ans,p[26][26],minv[26][26],sum[26],last[26];

char s[maxn];

int main()
{
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);

	scanf("%d",&n);
	scanf("%s",s+1);
	for (int a=1;a<=n;a++)
	{
		int c=s[a]-'a';
		sum[c]++;
		last[c]=a;
		for (int b=0;b<26;b++)
			if (b!=a && sum[b]) ans=max(ans,max(sum[c]-sum[b]-minv[c][b]-(last[b]==p[c][b]),sum[b]-sum[c]-minv[b][c]-(last[b]==p[b][c])));
		for (int b=0;b<26;b++)
		{
			if (sum[c]-sum[b]<minv[c][b]) minv[c][b]=sum[c]-sum[b],p[c][b]=a;
			if (sum[b]-sum[c]<minv[b][c]) minv[b][c]=sum[b]-sum[c],p[b][c]=a;
		}
	}
	printf("%d\n",ans);

	return 0;
}

信息

递交者
类型
递交
题目
字符串权值 T1
题目数据
下载
语言
C++
递交时间
2017-10-01 13:54:34
评测时间
2017-10-01 13:54:34
评测机
分数
0
总耗时
16ms
峰值内存
324.0 KiB