General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
61596944 Practice:
hjk1030
1070J - 29 C++17 (GCC 7-32) Accepted 78 ms 1184 KB 2019-10-01 12:13:58 2019-10-01 12:13:58
→ Source
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T,n,m,k,v[200010],cnt[26];
bool dp[200010];
char s[200010];
void solve()
{
	scanf("%d%d%d%s",&n,&m,&k,s+1);
	if(n<m)swap(n,m);
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=k;i++)v[i]=s[i]-'A',cnt[v[i]]++;
	long long ans=1e18;
	for(int i=0;i<26;i++)
	{
		fill(dp+1,dp+n+1,0);
		dp[0]=1;
		for(int j=0;j<26;j++)
		{
			if(j!=i)
			{
				for(int k=n-cnt[j];k>=0;k--)dp[k+cnt[j]]|=dp[k];
			}
		}
		for(int j=min(cnt[i],n);j>=0;j--)
		{
			if(dp[n-j])ans=min(ans,1ll*j*max(0,cnt[i]-j-(k-n-m)));
		}
	}
	printf("%lld\n",ans);
}
int main()
{
	scanf("%d",&T);
	while(T--)solve();
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details