File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .*;
2
+ import java .util .*;
3
+
4
+ public class Main {
5
+
6
+ public static void main (String [] args ) throws IOException {
7
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
8
+ StringTokenizer st = new StringTokenizer (br .readLine ());
9
+ int N = Integer .parseInt (st .nextToken ());
10
+ int M = Integer .parseInt (st .nextToken ());
11
+ int [][] graph = new int [N +1 ][N +1 ];
12
+ for (int i =1 ; i <=N ; i ++) {
13
+ for (int j =1 ; j <=N ; j ++) {
14
+ if (i == j ) {
15
+ graph [i ][j ] = 0 ;
16
+ }else {
17
+ graph [i ][j ] = 100 ;
18
+ }
19
+ }
20
+ }
21
+ for (int i =0 ; i <M ; i ++) {
22
+ st = new StringTokenizer (br .readLine ());
23
+ int A = Integer .parseInt (st .nextToken ());
24
+ int B = Integer .parseInt (st .nextToken ());
25
+ graph [A ][B ] = graph [B ][A ] = 1 ;
26
+ }
27
+
28
+ for (int k =1 ; k <=N ; k ++) {
29
+ for (int i =1 ; i <=N ; i ++) {
30
+ for (int j =1 ; j <=N ; j ++) {
31
+ graph [i ][j ] = Math .min (graph [i ][j ], graph [i ][k ] + graph [k ][j ]);
32
+ }
33
+ }
34
+ }
35
+ for (int i =1 ; i <=N ; i ++) {
36
+ for (int j =1 ; j <=N ; j ++) {
37
+ if (graph [i ][j ] > 6 ) {
38
+ System .out .println ("Big World!" );
39
+ return ;
40
+ }
41
+ }
42
+ }
43
+ System .out .println ("Small World!" );
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments