You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1007 B
33 lines
1007 B
#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;
|
|
} |