题意:给出n个名字及数字k,求出认识的人的个数(在k天之前见过的才算认识)
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 510;
int n, k;
char str[MAXN];
int count[MAXN];
bool input()
{
scanf("%d%d%s", &n, &k, str);
return true;
}
void solve()
{
int ans = 0;
memset(count, 0x00, sizeof(count));
for (int i = 0, len = strlen(str); i < len; i++) {
if (count[str[i] - 'A']) ans++;
count[str[i] - 'A']++;
if (i - k >= 0) count[str[i - k] - 'A']--;
}
printf("%d\n", ans);
}
int main() {
#ifndef ONLINE_JUDGE
freopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endif
int cas;
scanf("%d", &cas);
for (int i = 1; i <= cas; i++) {
input();
printf("Case %d: ", i);
solve();
}
return 0;
}