-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2630bj.cpp
More file actions
52 lines (44 loc) · 938 Bytes
/
2630bj.cpp
File metadata and controls
52 lines (44 loc) · 938 Bytes
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
#include <iostream>
using namespace std;
int board[130][130];
int n;
int cnt_white;
int cnt_blue;
bool check(int n,int x,int y) { //
for(int i=x;i<x+n;i++)
for (int j = y; j <y+n; j++)
{
//상하좌우 하나라도 다르면 false
if (board[i][j]!=board[x][y]) return false;
}
return true;
}
void func(int n,int x,int y) { //x=0 y=0
if (check(n,x,y)) {
if (board[x][y] == 1) cnt_blue++;
if (board[x][y] == 0) cnt_white++;
return;
}
else {
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
func(n / 2, x + i * n / 2 , y + j * n / 2); //4등분으로 잘라짐
}
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> board[i][j]; //하얀 0 파란 1
}
}
//알고리즘
func(n,0,0); //원점인 x=0 y=0 기준점
//출력
cout << cnt_white << '\n' << cnt_blue;
return 0;
}