-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2630.cpp
More file actions
50 lines (44 loc) · 1.22 KB
/
2630.cpp
File metadata and controls
50 lines (44 loc) · 1.22 KB
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
#include <bits/stdc++.h>
#define FastIO\
ios_base::sync_with_stdio(false);\
cin.tie(NULL);\
cout.tie(NULL);
using namespace std;
int white=0, blue=0;
bool check_paper(int x1, int x2, int y1, int y2, const vector<vector<int>>& color){
int first_color=color[y1][x1];
for(int i=y1; i<=y2; i++){
for(int j=x1; j<=x2; j++){
if(color[i][j]!=first_color){
return false;
}
}
}
return true;
}
void split_square(int x1, int x2, int y1, int y2, const vector<vector<int>>& color){//검사 영역
if(check_paper(x1, x2, y1, y2, color)){//다 같은 색이면
color[y1][x1] == 0 ? white++ : blue++;
}
else{
split_square(x1, (x2+x1)/2, y1, (y2+y1)/2, color);
split_square((x2+x1)/2+1, x2, y1, (y2+y1)/2, color);
split_square(x1, (x2+x1)/2, (y2+y1)/2+1, y2, color);
split_square((x2+x1)/2+1, x2, (y2+y1)/2+1,y2, color);
}
return;
}
int main(){
FastIO;
int n;
cin>>n;
vector<vector<int>> color(n, vector<int>(n));
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
cin>>color[i][j];
}
}
split_square(0, n-1, 0, n-1, color);
cout<<white<<"\n"<<blue;
return 0;
}