General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
44824702 Practice:
shaochengxi
1070J - 29 C++14 (GCC 6-32) Accepted 312 ms 328 KB 2018-10-25 08:07:43 2018-10-25 08:07:43
→ Source
#include<bits/stdc++.h>
using namespace std;
const int M=30005;
const int N=200005;
const int inf=0x3f3f3f3f;
char s[N];
int n,m,k,cnt[30],ans,dp[M];
int main(){
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%d%d%d",&n,&m,&k);
		scanf("%s",s+1);ans=inf;
		memset(cnt,0,sizeof(cnt));
		for (int i=1;i<=k;i++) cnt[s[i]-'A']++;
		for (int i=0;i<26;i++)
		if (cnt[i])
		{
			memset(dp,0,sizeof(dp));dp[0]=1;
			for (int j=0;j<26;j++)
			  if (j!=i)
			   for (int k=n;k>=cnt[j];k--) dp[k]|=dp[k-cnt[j]];
			for (int j=1;j<=cnt[i]&&j<=n;j++)//bitset要小心不要指入负数域 
			  if (dp[n-j]==1) ans=min(ans,j*max(cnt[i]-j-(k-n-m),0));
		}
		printf("%d\n",ans);
	}
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details