General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
68837302 Practice:
KyuushuKyuuhai
1070J - 29 GNU C++11 Accepted 170 ms 400 KB 2020-01-15 06:59:39 2020-01-15 06:59:39
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n,m,kk,cnt[30];bool dp[N];char s[N];
int main ()
{
    ios::sync_with_stdio(false);
    int T;cin >> T;
    while (T--)
    {
        cin >> n >> m >> kk >> (s + 1);if (n < m) swap(n,m);
        memset(cnt,0,sizeof(cnt));
        for (int i = 1;i <= kk;i++) cnt[s[i] - 'A']++;
        dp[0] = 1;long long ans = LLONG_MAX;
        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 >= cnt[j];--k)
                        dp[k] |= dp[k - cnt[j]];
            for (int j = 0;j <= min(cnt[i],n);j++)
                if (dp[n - j]) ans = min(ans,j * 1ll * max(cnt[i] - j - (kk - m - n),0));
        }
        cout << ans << endl;
    }
    return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details