Skip to content

Commit 84c23c2

Browse files
authored
[20251004] BOJ / G4 / 끝나지 않는 파티 / 이준희
1 parent 1ebbc5c commit 84c23c2

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
StringTokenizer st = new StringTokenizer(br.readLine());
10+
StringBuilder sb = new StringBuilder();
11+
12+
int n = Integer.parseInt(st.nextToken());
13+
int m = Integer.parseInt(st.nextToken());
14+
15+
int[][] map = new int[n][n];
16+
17+
for (int i = 0; i < n; i++) {
18+
st = new StringTokenizer(br.readLine());
19+
for (int j = 0; j < n; j++) {
20+
map[i][j] = Integer.parseInt(st.nextToken());
21+
}
22+
}
23+
24+
for (int k = 0; k < n; k++) {
25+
for (int i = 0; i < n; i++) {
26+
for (int j = 0; j < n; j++) {
27+
map[i][j] = Math.min(map[i][j], map[i][k] + map[k][j]);
28+
}
29+
}
30+
}
31+
32+
for (int i = 0; i < m; i++) {
33+
st = new StringTokenizer(br.readLine());
34+
int from = Integer.parseInt(st.nextToken()) - 1;
35+
int to = Integer.parseInt(st.nextToken()) - 1;
36+
int limit = Integer.parseInt(st.nextToken());
37+
if (map[from][to] <= limit) {
38+
sb.append("Enjoy other party\n");
39+
} else {
40+
sb.append("Stay here\n");
41+
}
42+
}
43+
44+
System.out.println(sb.toString());
45+
}
46+
}
47+
```

0 commit comments

Comments
 (0)