Created
November 28, 2016 10:08
-
-
Save HyeonWooKim/6ee612b6b80018a89c042372a611cc48 to your computer and use it in GitHub Desktop.
BOJ 1780
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
using namespace std; | |
int w[2222][2222],d[3]; | |
void dfs(int x, int y, int k) | |
{ | |
bool f = true; | |
int cmp = w[x][y]; | |
for (int i = x; i < x + k && f; i++) | |
for (int j = y; j < y + k && f; j++) | |
if (w[i][j] != cmp) | |
{ | |
f = false; | |
int t = k / 3; | |
for (int a = x, b = 0; b < 3; a += t, b++) | |
for (int c = y, d = 0; d < 3; c += t, d++) | |
dfs(a, c, t); | |
} | |
if(f) d[cmp + 1]++; | |
} | |
int main() | |
{ | |
int n; | |
scanf("%d", &n); | |
for (int i = 0; i < n; i++) | |
for (int j = 0; j < n; j++) | |
scanf("%d", &w[i][j]); | |
dfs(0, 0, n); | |
for (int i : d) cout << i << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment