General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
46269251 Practice:
_ChenKerui
1070J - 29 GNU C++11 Happy New Year! 93 ms 2944 KB 2018-11-27 09:37:43 2018-11-27 09:37:43
 
 
→ Source
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,m,K,T,ans,cnt[N];bool dp[N];char s[N];
inline void count(int x){
	dp[0]=1;for (int i=1;i<=n+m;i++) dp[i]=0;
	for (int i=1;i<=26;i++){
		if (i==x) continue;
		for (int j=n;j>=cnt[i];j--) dp[j]|=dp[j-cnt[i]];
	}
	for (int i=0;i<=n;i++){
		if (dp[i]){
			int L=max(0,n-i);
			int R=max(0,m-(K-cnt[x]-i));
			if (L+R>cnt[x]) continue;
			else ans=min(ans,L*R);
		}
	}
}
inline void solve(){
	scanf("%d%d%d",&n,&m,&K);
	scanf("%s",s+1);ans=1e9;
	for (int i=1;i<=26;i++) cnt[i]=0;
	for (int i=1;i<=K;i++) cnt[s[i]-'A'+1]++;
	for (int i=1;i<=26;i++) count(i);
	printf("%d\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