-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquardtree_temp.cpp
54 lines (42 loc) · 1.04 KB
/
quardtree_temp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
using namespace std;
int N, white = 0, blue = 0;
int arr[130][130]={0,};
void division(int x, int y, int size){
int cnt = 0; // 0이면 all white, 최대값일 경우 all blue
for(int i=x; i< x+size; i++)
for(int j=y; j< y+size; j++)
if(arr[i][j] == 1) cnt++;
if(cnt == 0) white++;
else if( cnt == size*size) blue++;
else {
division(x, y, size/2);
division(x, y + size/2, size/2);
division(x + size/2, y, size/2);
division(x + size/2, y + size/2, size/2);
}
}
int main(){
cin >> N;
for(int i=0; i<N; i++)
for(int j=0; j<N; j++)
cin >> arr[i][j];
division(0,0,N);
cout << white << endl; // 0
cout << blue << endl; // 1
}
// ((1000)(0110)((1001)001)1)
/*
모두 같은 숫자이면 그대로 진행, blue인지 white인지 카운트
하나라도 다를경우
N/2를 해서 재귀
8
1 1 0 0 0 0 1 1
1 1 0 0 0 0 1 1
0 0 0 0 1 1 0 0
0 0 0 0 1 1 0 0
1 0 0 0 1 1 1 1
0 1 0 0 1 1 1 1
0 0 1 1 1 1 1 1
0 0 1 1 1 1 1 1
*/