-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2630.cpp
More file actions
43 lines (38 loc) · 963 Bytes
/
2630.cpp
File metadata and controls
43 lines (38 loc) · 963 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
#include <bits/stdc++.h>
#define SETTING ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
using namespace std ;
int N, zero_num, one_num ;
int arr[129][129] ;
void DivAndCon(int N, int row, int col)
{
bool toggle = arr[row][col] ;
bool flag = 0 ;
for(int i = 0 ; i < N ; i++)
for(int j = 0 ; j < N ; j++)
if(toggle != arr[row + i][col + j])
{
flag = 1 ; break ;
}
if(flag)
{
DivAndCon(N / 2, row , col) ;
DivAndCon(N / 2, row, col + (N / 2)) ;
DivAndCon(N / 2, row + (N / 2), col) ;
DivAndCon(N / 2, row + (N / 2), col + (N / 2)) ;
}
else
{
toggle ? one_num++ : zero_num++ ;
}
}
int main()
{
SETTING ;
cin >> N ;
for(int i = 1 ; i <= N ; i++)
for(int j = 1 ; j <= N ; j++)
cin >> arr[i][j] ;
DivAndCon(N, 1, 1) ;
cout << zero_num << endl << one_num << endl ;
}