Skip to content

Commit 7e81dbe

Browse files
authored
Merge pull request #733 from AlgorithmWithGod/suyeun84
[20250824] BOJ / G4 / 끝나지 않는 파티 / 김수연
2 parents 4831ed5 + 36b71e1 commit 7e81dbe

File tree

1 file changed

+44
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)