General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
44887931 Practice:
dwt
1070J - 29 GNU C++14 Happy New Year! 936 ms 208 KB 2018-10-26 03:20:06 2018-10-26 03:20:06
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;
#define N 30010
bitset<N>dp;
int cnt[26];
char s[200010];
void init(){
	memset(cnt,0,sizeof(cnt));
}
void solve(){
	int n,m,K;
	scanf("%d%d%d",&n,&m,&K);
	scanf("%s",s+1);
	for (int i=1;i<=K;i++) cnt[s[i]-'A']++;
	long long ans=1e18;
	for (int i=0;i<26 && ans>0;i++){
		if (!cnt[i]) continue;
		dp.reset();
		dp[0]=1;
		for (int j=0;j<26;j++){
			if (j==i) continue;
			dp|=dp<<cnt[j];
		}
		for (int j=dp._Find_first();j<dp.size() && j<=n;j=dp._Find_next(j)){
			if (j+cnt[i]<=n) continue;
		//	printf("%d\n",j);
			ans=min(ans,1LL*(n-j)*max((m-((K-cnt[i])-j)),0));
		}
	}
	printf("%lld\n",ans);
}
signed main(){
	int T; scanf("%d",&T);
	while (T--){init();solve();}
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details