# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
44657060 |
Practice:
AKCqhzdy |
1070J
- 29
|
C++14 (GCC 6-32)
|
Accepted
|
545 ms
|
248 KB
|
2018-10-21 16:28:13 |
2018-10-21 16:28:13 |
|
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
char ss[210000];
int c[30];
bool f[31000];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,m,K;
scanf("%d%d%d",&n,&m,&K);
scanf("%s",ss+1);
memset(c,0,sizeof(c));
for(int i=1;i<=K;i++)c[ss[i]-'A'+1]++;
int ans=(1<<30);
for(int i=1;i<=26;i++)
{
memset(f,false,sizeof(f));f[0]=true;
for(int j=1;j<=26;j++)
{
if(i==j||c[j]==0)continue;
for(int k=n;k>=c[j];k--)f[k]|=f[k-c[j]];
}
for(int k=0;k<=n;k++)
if(f[k]==true)
{
int h=max(0,n-k),l=max(0,m-(K-c[i]-k));
if(h+l<=c[i])ans=min(ans,h*l);
}
}
printf("%d\n",ans);
}
return 0;
}
Click to see test details