题目链接
https://vjudge.net/problem/CodeForces-984B
题意
扫雷,给你一片地图,问你是否是有效的,即数字显示得是否正确。
思路
用一个数组记录正确的周围雷的个数,初始化都为0。读入后,遇到雷就把周围的格子都加一。最后把不是雷的地方都看一遍,看看是否和记录的相同。
AC代码
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<string>
#include<sstream>
#include<cctype>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1000000007;
const int maxn = 100010;
char s[maxn];
int a[52];
int n, len;
int readin()
{
scanf("%s", s);
len = strlen(s);
memset(a, 0, sizeof(a));
for(int i = 0; i < len; i++)
{
if(s[i] >= 'a' && s[i] <= 'z')
a[s[i] - 'a']++;
else
a[s[i] - 'A' + 26]++;
}
int mx = 0;
for(int i = 0; i < 52; i++)
{
if(a[i] > mx)
mx = a[i];
}
if(mx == len && n == 1)
mx = mx - 1;
else
mx = min(len, mx + n);
return mx;
}
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int x, y, z;
scanf("%d", &n);
x = readin();
y = readin();
z = readin();
int ans[3] = {x, y, z};
sort(ans, ans + 3);
if(ans[2] == ans[1])
{
printf("Draw\n");
}
else
{
if(ans[2] == x)
printf("Kuro\n");
else if(ans[2] == y)
printf("Shiro\n");
else
printf("Katie\n");
}
return 0;
}