-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1051.cpp
50 lines (45 loc) · 999 Bytes
/
1051.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int arr[50][50];
int main() {
int col, row;
cin >> col >> row;
int small = min(col, row) - 1;
for (int i = 0; i < col; ++i) {
for (int j = 0; j < row; ++j) {
scanf_s("%1d", &arr[j][i]);
}
}
if (row > col) {
for (int i = 0; i + small < col; ++i) {
for (int j = 0; j + small < row; ++j) {
if (arr[j][i] == arr[j + small][i] && arr[j][i] == arr[j + small][i + small] && arr[j][i] == arr[j][i + small]) {
cout << (small + 1) * (small + 1);
return 0;
}
}
--small;
if (small == 0) {
cout << 1;
return 0;
}
}
}
else {
for (int i = 0; i + small < col; ++i) {
for (int j = 0; j + small < row; ++j) {
if (arr[i][j] == arr[i + small][j] && arr[i][j] == arr[i + small][j + small] && arr[i][j] == arr[i][j + small]) {
cout << (small + 1) * (small + 1);
return 0;
}
}
--small;
if (small == 0) {
cout << 1;
return 0;
}
}
}
}