Files
python/TangDou/LanQiaoBei/ZhongGaoJi/LanQiao14STEMA202301/BC4.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

33 lines
1007 B
C++

#include <bits/stdc++.h>
using namespace std;
const int N = 31;
char a[N][N];
int n, m, cnt;
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cin >> a[i][j]; // a,b,c
for (int e = 2; e <= min(m, n); e++) { // 枚举每个小正方形的边长
for (int i = 0; i <= n - e; i++) { // 起点i
for (int j = 0; j <= m - e; j++) { // 起点j
bool f = true;
for (int x = 0; x < e; x++) { // 遍历正方形中所有的其它位置,判断是不是与左上角的一致
for (int y = 0; y < e; y++) {
if (a[i][j] != a[i + x][j + y]) {
f = false;
break;
}
}
if (!f) break;
}
if (f) cnt++;
}
}
}
cout << cnt << endl;
return 0;
}