최's 먹공로그
SEA7236_저수지의 물의 총 깊이 구하기 본문
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class Solution {
static int[] dx = {-1,0,1,0,1,1,-1,-1};
static int[] dy = {0,-1,0,1,-1,1,1,-1};
static int cnt;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int test_case = Integer.parseInt(br.readLine().trim());
for (int tc = 1; tc <= test_case; tc++) {
int N = Integer.parseInt(br.readLine().trim());
//String[][] map = new String[N][N];
char[][] map = new char[N][N];
for (int i = 0; i < N; i++) {
//StringTokenizer st = new StringTokenizer(br.readLine().trim(), " ");
String[] s = br.readLine().split(" ");
//System.out.println(Arrays.toString(s));
for (int j = 0; j < N; j++) {
//map[i][j] = st.nextToken();
map[i][j] = s[j].charAt(0);
}
}
int max = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cnt = 0;
// 현재 값이 물일때만
if(map[i][j] == 'W') {
solve(map, i, j, N);
}
if(max < cnt) {
max = cnt;
}
}
}
if(max <= 0) {
System.out.println("#" + tc + " " + 1);
}
else {
System.out.println("#" + tc + " " + max);
}
} // end of tc
} // end of main
private static void solve(char[][] map, int x, int y, int size) {
for (int i = 0; i < 8; i++) {
int nx = x + dx[i];
int ny = y + dy[i];
if(nx>=0 && nx<size && ny>=0 && ny<size) {
// 주변이 물일때만 ++
if(map[nx][ny] == 'W') {
cnt++;
}
}
}
} // end of solve
} // end of class
|
cs |
'APS' 카테고리의 다른 글
BOJ7569_토마토 (0) | 2019.03.12 |
---|---|
BOJ7576_토마토 (0) | 2019.03.12 |
SEA1861_정사각형 방 (0) | 2019.03.10 |
SEA7234_안전 기지(User Problem) (2) | 2019.03.07 |
SEA3752_가능한 시험점수 (0) | 2019.03.07 |