#include <iostream> #include <algorithm> using namespace std; int row, col; int map[1010][1010]; int Max; int main(void) { // freopen("B1915_input.txt", "r", stdin); cin >> row >> col; for(int i = 1; i <= row; i++) { for(int j = 1; j <= col; j++) { scanf("%1d", &map[i][j]); } } if(row == 1 || col == 1) { for(int i = 1; i <= row; i++) { for(int j = 1; j <= col; j++) { if(map[i][j] == 1) { Max = 1; break; } } } } else { for(int i = 1; i <= row; i++) { for(int j = 1; j <= col; j++) { if(map[i][j] != 0) { map[i][j] = min({map[i-1][j], map[i][j-1], map[i-1][j-1]}) + 1; Max = max(Max, map[i][j]); } } } } cout << Max * Max; return 0; } | cs |
'Baekjoon > DP' 카테고리의 다른 글
[백준 1904] 타일 (DP) (C/C++) (0) | 2020.03.22 |
---|---|
[백준 2096] 내려가기 (DP) (C/C++) (★★) (0) | 2020.03.22 |
[백준 11051] 이항 계수 2 (DP) (C/C++) (0) | 2020.03.17 |
[백준 2186] 문자판 (DFS, DP) (C/C++) (★★★) (0) | 2020.03.17 |
[백준 1520] 내리막 길 (DFS, DP) (C/C++) (★★) (0) | 2020.03.17 |