不难......
2024-05-14 22:11:24
发布于:浙江
9阅读
0回复
0点赞
某谷传送门
就暴力搜索呗,又不难
代码:
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
char a[1005][1005];
int n, m, sum = 0;
cin >> n >> m;
for (int i = 1; i <= n; ++i)for(int j=1;j<=m;j++)cin>>a[i][j];
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j) {
if (a[i][j] == 'h' && a[i][j - 1] == 'e' && a[i][j - 2] == 'h' && a[i][j - 3] == 'e')sum++;
if (a[i][j] == 'h' && a[i][j + 1] == 'e' && a[i][j + 2] == 'h' && a[i][j + 3] == 'e')sum++;
if (a[i][j] == 'h' && a[i - 1][j] == 'e' && a[i - 2][j] == 'h' && a[i - 3][j] == 'e')sum++;
if (a[i][j] == 'h' && a[i + 1][j] == 'e' && a[i + 2][j] == 'h' && a[i + 3][j] == 'e')sum++;
}
cout << sum << endl;
}//进行了"一定的"压行,怎么搞看你了
这里空空如也
有帮助,赞一个