-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1780.cpp
More file actions
54 lines (50 loc) · 1.4 KB
/
1780.cpp
File metadata and controls
54 lines (50 loc) · 1.4 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
51
52
53
54
#include <iostream>
#include <math.h>
#define SETTING ios::sync_with_stdio(0), cin.tie(0)
using namespace std ;
int SIZE, minbox, zerobox, onebox ;
int arr[2188][2188] ;
void InputSetting()
{
cin >> SIZE ;
for(int i = 1 ; i <= SIZE ; i++)
for(int j = 1 ; j <= SIZE ; j++)
cin >> arr[i][j] ;
}
void DivAndCon(int row, int col, int asize)
{
int end_row = row + asize ;
int end_col = col + asize ;
int prev = arr[row][col] ;
if(asize > 1)
for(int start_row = row ; start_row < end_row ; start_row++)
{
for(int start_col = col ; start_col < end_col ; start_col++)
{
if(arr[start_row][start_col] != prev)
{
for(int i = 0 ; i < 3 ; i++)
for(int j = 0 ; j < 3 ; j++)
{
int temp_size = asize / 3 ;
DivAndCon(row + i * temp_size, col + j * temp_size, temp_size) ;
}
return ;
}
prev = arr[start_row][start_col] ;
}
}
switch(prev)
{
case -1 : {minbox++ ; break ;}
case 0 : {zerobox++ ; break ;}
case 1 : {onebox++ ; break ; }
}
}
int main()
{
SETTING ;
InputSetting() ;
DivAndCon(1,1, SIZE) ;
cout << minbox << "\n" << zerobox << "\n" << onebox ;
}