Source Code
Problem: 1406 User: 20220556****
Memory: 1200K Time: 249MS
Language: GCC Result: Accepted
Source Code
#include <stdio.h>
#include <string.h>
int score(int countmax, int len, int playtime)
{
if (countmax + playtime <= len)
{
return countmax + playtime;
}
else if (countmax == len)
{
if (playtime == 1)
{
return len - 1;
}
else
{
return len;
}
}
else if (countmax + playtime > len)
{
return len;
}
}
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, p;
scanf("%d %d", &n, &p);
char Alice[105], Bob[105];
scanf("%s", Alice);
scanf("%s", Bob);
int countAlice[26] = {0}, countBob[26] = {0};
int alice = 0, bob = 0, countalicemax = 0, countbobmax = 0;
for (int i = 0; i < n; i++)
{
countAlice[Alice[i] - 'a']++;
countBob[Bob[i] - 'a']++;
}
for (int i = 0; i < 26; i++)
{
if (countAlice[i] > countalicemax)
countalicemax = countAlice[i];
if (countBob[i] > countbobmax)
countbobmax = countBob[i];
}
alice = score(countalicemax, n, p);
bob = score(countbobmax, n, p);
if (alice > bob)
{
printf("Alice\n");
continue;
}
else if (alice == bob)
{
printf("Draw\n");
continue;
}
else if (alice < bob)
{
printf("Bob\n");
continue;
}
}
}
找到计分规则就好了
首先要找到最多的字母的数量,你要赢肯定要变最多的
当回合数不够时打尽力局,最高分为最大的字母加回合数
当回合数大于补满所要的步数时,若刚刚好大一个,只能的max-1分,因为比如wwwwwwww你要改变一个就会少一分
当回合数不止大一个时直接拉满
比如wwwwwwww还有大于一次的机会你就w->x->w或者w->q->p->....->w