[백준] 2630 색종이 만들기
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int n;
vector<vector<int>> board;
int white = 0;
int blue = 0;
void solution(int startR, int startC, int size) {
	int color = board[startR][startC];
	
	bool sameColor = true;
	for (int r = startR; r < startR + size; ++r) {
		for (int c = startC; c < startC + size; ++c) {
			if (board[r][c] != color) {
				sameColor = false;
				break;
			}
		}
		if (!sameColor) break;
	}
	if (sameColor) {
		if (color == 0) white++;
		else blue++;
		return;
	}
	
	int halfSize = size / 2;
	solution(startR, startC, halfSize);
	solution(startR, startC + halfSize, halfSize);
	solution(startR + halfSize, startC, halfSize);
	solution(startR + halfSize, startC + halfSize, halfSize);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		vector<int> row;
		for (int j = 0; j < n; ++j) {
			int input;
			cin >> input;
			row.push_back(input);
		}
		board.push_back(row);
	}
	solution(0, 0, n);
	cout << white << "\n" << blue;
	return 0;
}