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.

31 lines
819 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];
for (int e = 2; e <= min(m, n);e++){
for (int i = 0; i <= n - e;i++){
for (int j = 0; j <= m - e;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;
}