Scroll indicator done
728x90

https://www.acmicpc.net/problem/1780


#include <iostream>
using namespace std;

int n;
int p[2188][2188];
int cnt[3]; // -1,0,1

void f(int x, int y, int size) {
	bool isSame = true;
	for (int i = x; i < x + size; i++) {
		for (int j = y; j < y + size; j++) {
			if (p[x][y] != p[i][j]) {
				isSame = false;
				break;
			}
		}
	}

	if (isSame) {
		cnt[p[x][y] + 1]++;
		return;
	}
	
	for (int i = x; i < x + size; i += size / 3) {
		for (int j = y; j < y + size; j += size / 3) {
			f(i, j, size / 3);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < n; j++) 
			cin >> p[i][j];

	f(0, 0, n);

	for (int i = 0; i < 3; i++) 
		cout << cnt[i] << '\n';
}

728x90

'BAEKJOON > C++' 카테고리의 다른 글

[B5525][IOIOI][C++]  (0) 2021.07.02
[B1268][임시 반장 정하기][C++]  (0) 2021.07.01
[B9375][패션왕 신해빈][C++]  (0) 2021.06.29
[B11727][2xn 타일링 2][C++]  (0) 2021.06.29
[B1541][잃어버린 괄호][C++]  (0) 2021.06.25