-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_1051.cpp
More file actions
40 lines (35 loc) · 749 Bytes
/
BOJ_1051.cpp
File metadata and controls
40 lines (35 loc) · 749 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
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
int k = 1;
int result = 1;
int counter = 0;
int arr[51][51] = { 0 };
string input;
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> input;
for (int j = 0; j < input.size(); j++) {
arr[i][j] = input[j]-'0';
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
counter = 0;
for (int k = 1;; k++) {
if ((j + k) >= m || (i + k) >= n) break;
if (arr[i][j] == arr[i][j + k] && arr[i][j] == arr[i + k][j] && arr[i][j] == arr[i + k][j + k]) // square
{
if (counter < k) { // update counter
counter = k;
}
}
}
if ((counter + 1) > result) {
result = counter + 1;
}
}
}
cout << result * result;
}