-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1051.cpp
More file actions
35 lines (33 loc) · 910 Bytes
/
1051.cpp
File metadata and controls
35 lines (33 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <algorithm>
using namespace std;
char arr[51][51];
int main(){
int n, m; cin>>n>>m;
int maximum = min(n,m);
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
cin>>arr[i][j];
}
}
int result=1;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
for(int a=1; a<=maximum; a++){
if(i+a > n) break;
if(j+a > m) break;
char temp = arr[i][j];
//cout<<temp<<" "<<arr[i+a][j]<<" "<<arr[i][j+a]<<" "<<arr[i+a][j+a]<<endl;
if(temp==arr[i+a][j]){
if(temp==arr[i][j+a]){
if(temp==arr[i+a][j+a]){
result = max(result, (a+1)*(a+1));
}
}
}
}
}
}
cout<<result<<endl;
return 0;
}