General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
46926452 Practice:
luogu_bot2
1070J - 29 GNU C++11 Accepted 2152 ms 332 KB 2018-12-12 11:59:57 2018-12-12 11:59:57
 
 
→ Source
#include<bits/stdc++.h>
using namespace std;

#define read(x) scanf("%d",&x)
#define maxn 30000
#define maxk 200000

int n,m,K;
int cnt[30];
int f[maxn+5];
char a[maxk+5];

int main() {
	int T;
	read(T);
	while(T--) {
		memset(cnt,0,sizeof(cnt));

		read(n),read(m),read(K);
		if(n<m) swap(n,m);
		scanf("%s",a+1);
		for(int i=1; i<=K; i++) cnt[a[i]-'A'+1]++;

		int ans=(int)1e9;
		for(int i=1; i<=26; i++) {
			memset(f,0,sizeof(f));
			f[0]=true;
			for(int k=1; k<=26; k++) {
				if(i==k) continue;
				for(int j=n; j>=1; j--) {
					if(j>=cnt[k]) f[j]|=f[j-cnt[k]];
				}
			}
			for(int j=0; j<=min(cnt[i],n); j++) {
				int k=cnt[i]-j-(K-m-n);
				if(f[n-j]) ans=min(ans,j*(k>0?k: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