-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1780.java
More file actions
54 lines (42 loc) · 810 Bytes
/
P1780.java
File metadata and controls
54 lines (42 loc) · 810 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
53
54
package BOJ;
import java.util.*;
public class P1780 {
static int[][] map;
static int[] cnt;
public static void div(int x, int y, int n){
if(check(x,y,n)){
cnt[map[x][y]+1]+=1;
return;
}
int m = n/3;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
div(x+i*m, y+j*m,m);
}
}
}
public static boolean check(int x, int y, int n){
for(int i=x;i<x+n;i++){
for(int j=y;j<y+n;j++){
if(map[x][y] != map[i][j])
return false;
}
}
return true;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
map = new int[n][n];
cnt = new int[3];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
map[i][j] = sc.nextInt();
}
}
div(0,0,n);
for(int x : cnt){
System.out.println(x);
}
}
}