parent
e1d3d97e75
commit
3b907ba4bf
@ -0,0 +1,33 @@
|
|||||||
|
#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];
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in new issue