General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
44723270 Practice:
Lgq_3de5
1070J - 29 GNU C++14 Accepted 530 ms 404 KB 2018-10-23 09:40:10 2018-10-23 09:40:11
 
 
→ Source
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int S=26;
const int maxn=2e5+5;
int cnt[S];
bool dp[maxn];
char St[maxn];
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n,m,s;
		cin >> n >> m >> s;
		memset(cnt,0,sizeof(cnt));
		cin >> St;
		long long ans=1e18+5;
		for (int i=0;i<s;i++)
			cnt[St[i]-'A']++;
		for (int i=0;i<26;i++)
		{
			if (cnt[i]==0) continue;
			memset(dp,false,sizeof(dp));
			dp[0]=true;
			for (int j=0;j<26;j++)
			{
				if (i==j) continue;
				if (cnt[j]!=0)
				for (int k=n-cnt[j];k>=0;k--)
					if (dp[k])
						dp[k+cnt[j]]=1;
			}
			for (int k=max(n-cnt[i],0);k<=n;k++)
				if (dp[k])
					ans=min(ans,1ll*(n-k)*max(0,m-(s-k-cnt[i])));
		}
		cout << ans << endl;		
	}
}/*2
2 7 9
EEZZEEZZZ*/
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details