728x90
programmers.co.kr/learn/courses/30/lessons/12905
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
int solution(vector<vector<int>> board) {
int answer = 1;
for(int i=1;i<board.size();i++){
for(int j=1;j<board[i].size();j++){
if(board[i][j] &&
board[i][j-1] && board[i-1][j] && board[i-1][j-1]){
board[i][j] = min(min(board[i][j-1],board[i-1][j]),board[i-1][j-1])+1;
if(board[i][j]>answer) answer = board[i][j];
}
}
}
int zero_chk = 0;
for(int i=0;i<board.size();i++){
for(int j=0;j<board[i].size();j++){
zero_chk+=board[i][j];
}
}
if(zero_chk == 0) return 0;
return answer*answer;
}