General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
45119635 Practice:
ccsu_cat_love_jiejie
1070J - 29 GNU C++11 Accepted 186 ms 992 KB 2018-10-31 05:46:47 2018-10-31 05:46:47
 
 
→ Source
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=2e5+10;
char s[maxn];
int c[26],f[maxn];
int main()
{
	int T;
	scanf("%d",&T);
	f[0]=1;
	while(T--)
	{
		int a,b,n;
		memset(c,0,sizeof(c));
		cin>>a>>b>>n;
		scanf("%s",s+1);
		for(int i=1;i<=n;i++)
		c[s[i]-'A']++;
		int ans=1e9;
		for(int i=0;i<26;i++)
		{
			for(int j=1;j<=a;j++)
			f[j]=0;
			for(int j=0;j<26;j++)
			{
				if(i==j||c[j]==0)continue;
				for(int k=a;k>=c[j];k--)
				f[k]|=f[k-c[j]];
			}
			for(int j=0;j<=a;j++)
			if(f[j])
			{
				int l=max(0,a-j);
				//int l=min(a-j,c[i]);
				int r=max(0,b-(n-j-c[i]));
				//printf("l=%d r=%d c=%d i=%d\n",l,r,c[i],i);
				if(l+r<=c[i])ans=min(ans,l*r);
			}
		}
		cout<<ans<<"\n";
	}
}
 
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details