File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments