#include <vector>
#include <string.h>
using namespace std;
int pic[100][100];
bool check[100][100];
int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
int recursive(int x, int y, int m, int n, int value){
check[x][y] = true;
int area = 0;
for(int i=0; i<4; i++){
int new_x = x + dir[i][0];
int new_y = y + dir[i][1];
if(new_x < 0 || new_y < 0 || new_x >= m || new_y >= n)
continue;
if(check[new_x][new_y] == true || pic[new_x][new_y] != value)
continue;
area += recursive(new_x, new_y, m, n, value);
}
return area + 1;
}
// 전역 변수를 정의할 경우 함수 내에 초기화 코드를 꼭 작성해주세요.
vector<int> solution(int m, int n, vector<vector<int>> picture) {
int number_of_area = 0;
int max_size_of_one_area = 0;
memset(pic, 0, sizeof(pic));
memset(check, false, sizeof(check));
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
pic[i][j] = picture[i][j];
}
}
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
if(check[i][j]==false && pic[i][j]!=0){
number_of_area++;
int area = recursive(i, j, m, n, pic[i][j]);
if(max_size_of_one_area < area)
max_size_of_one_area = area;
}
}
}
vector<int> answer(2);
answer[0] = number_of_area;
answer[1] = max_size_of_one_area;
return answer;
}