#include <iostream>
using namespace std;
int board[128][128];
int c_white(0), c_blue(0);
void Func(int n, int base_r, int base_c)
{
if (n == 0)
return;
bool isSame = true;
int color = board[base_r][base_c];
for (int r = base_r; r < base_r + n && isSame; r++)
{
for (int c = base_c; c < base_c + n; c++)
{
if (color != board[r][c])
{
isSame = false;
break;
}
}
}
if (isSame)
{
if (color) // 파란색
++c_blue;
else // 하얀색
++c_white;
}
else
{
int new_n = n / 2;
for (int i = 0; i < 4; i++)
{
int new_r = base_r + new_n * (i / 2);
int new_c = base_c + new_n * (i % 2);
Func(new_n, new_r, new_c);
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
cin >> board[i][j];
Func(N, 0, 0);
cout << c_white << '\n' << c_blue;
return 0;
}
댓글남기기