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
|
import java.io.FileInputStream;
/*
3
NYY
YNY
YYN
* */
public class Main {
static int N;
static char[] cmap;
static int[][] map;
static int result;
public static void main(String[] args) throws Exception{
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
map = new int[N][N];
for(int i = 0; i<map.length; i++) {
cmap = c.toCharArray();
for(int j = 0; j<map[i].length; j++) {
if(cmap[j] =='Y') {
map[i][j] = 1;
}else {
map[i][j] = 9999;
}
}
}
for(int i = 0; i<N; i++) {
for(int j = 0 ; j<N; j++) {
for(int k = 0 ; k<N; k++) {
if(i == j|| j==k || i==k) {
continue;
}else if(map[i][j] > map[i][k] + map[k][j]) {
map[i][j] = map[i][k] + map[k][j];
}
}
}
}
for(int i = 0; i<map.length; i++) {
int sum = 0;
for(int j = 0 ; j<map[i].length; j++) {
if(i==j) continue;
else if(map[i][j] <=2 ) sum++;
}
result = Math.max(result, sum);
}
System.out.println(result);
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'it > 알고리즘' 카테고리의 다른 글
백준 1260 - DFS와 BFS (0) | 2019.12.17 |
---|---|
백준 1110 - 더하기 사이클 (0) | 2019.12.17 |
백준 1012 - 유기농 배추 (0) | 2019.12.17 |
백준 10026 - 적록색약 (0) | 2019.09.01 |
백준 11057 - 오르막 수 (0) | 2019.09.01 |