General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
132443536 Practice:
The_way_to_Rome
1070J - 29 GNU C++14 Accepted 62 ms 324 KB 2021-10-19 16:22:29 2021-10-19 16:22:29
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;
const int N = 3e4 + 5,inf = 0x3f3f3f3f;
int ton[26];
int n,m,k,dp[N];
const int L = 2e5 + 5;
char s[L];
inline void work()
{
	for(int i=1;i<=26;i++) ton[i-1] = 0;
	scanf("%d%d%d",&n,&m,&k);
	if(n < m) swap(n,m);
	dp[0] = 1;
	scanf("%s",s+1);
	int ans = inf;
	for(int i=1;i<=k;i++) ton[s[i]-'A']++;
	for(int i=0;i<26;i++)
	{
		for(int j=1;j<=n;j++) dp[j] = 0;
		for(int j=0;j<26;j++)
			if(i!=j)
				for(int k=n;k>=ton[j];k--)
					dp[k] = dp[k] | dp[k-ton[j]];
		for(int j=0;j<=min(ton[i],n);j++)
			if(dp[n-j])
			{
				ans = min(ans,j*max(0,ton[i] - j -(k-m-n)));
			}
	}
	printf("%d\n",ans);
}
int main()
{
	int T;
	cin>>T;
	while(T--) work();
	return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details