|

General

# Author Problem Lang Verdict Time Memory Sent Judged
54262081 Practice:
vjudge2
1070J - 29 GNU C++14 Happy New Year! 46 ms 992 KB 2019-05-17 05:50:00 2019-05-17 05:50:00

→ Source
// Onlt a test
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
const int Div=1013503;
const int Inf=0x3f3f3f3f;
int T;
int n,m,K;
char s[maxn];
int cnt[29];
int f[maxn];
inline void Run(int Ban){
memset(f,0,sizeof(int)*(K+3));
f[0]=1;
for(int i=1;i<=26;i++)if(i^Ban)
for(int j=K;j>=cnt[i];j--)f[j]|=f[j-cnt[i]];
}
int main(){
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&n,&m,&K);
scanf("%s",s+1);
memset(cnt,0,sizeof(cnt));
for(int i=1;i<=K;i++)cnt[s[i]-'A'+1]++;
Run(0);
bool flag=0;
for(int i=n;i+m<=K;i++)if(f[i]){flag=1;break;}
if(flag){puts("0");continue;}
int Ans=Inf;
for(int i=1;i<=26;i++)if(cnt[i]>1){
Run(i);
for(int j=0;j<=K;j++)if(f[j]&&max(n-j,0)+max(m-(K-j-cnt[i]),0)<=cnt[i]){
Ans=min(Ans,max(n-j,0)*max(m-(K-j-cnt[i]),0));
}
}
printf("%d\n",Ans);
}
return 0;
}


?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
?
?
?