forked from gojung/AlgorithmStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_2805.java
More file actions
40 lines (37 loc) · 1.43 KB
/
java_2805.java
File metadata and controls
40 lines (37 loc) · 1.43 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
//SWEA 2805 ³óÀÛ¹° ¼öÈ®Çϱâ(D3)
import java.io.*;
public class java_2805 {
public static void main(String[] args) throws Exception{
//BufferedReader br = new BufferedReader(new FileReader("test.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int [][]board = new int[49][49];
int T = Integer.parseInt(br.readLine());
for(int t = 1; t <= T; t++){
int sum = 0;
int N = Integer.parseInt(br.readLine());
for(int i = 0; i < N; i++){
String str = br.readLine();
for(int j = 0; j < N; j++){
board[i][j] = str.charAt(j) - '0';
sum += board[i][j];
}
}
/*do*/
for(int i = 0; i < N/2; i++)
for(int j = 0; j < N/2-i; j++)
sum -= board[i][j];
for(int i = 0; i < N/2; i++)
for(int j = N/2+1+i; j < N; j++)
sum -= board[i][j];
for(int i = N/2+1; i<N; i++)
for(int j = 0; j < i-N/2; j++)
sum-= board[i][j];
for(int i = N/2+1; i < N; i++)
for(int j = N-i+N/2; j < N; j++)
sum-= board[i][j];
sb.append("#" + t + " " + sum + "\n");
} //EOT
System.out.print(sb);
}
}