55
66/*
77 * Author : joney_000[developer.jaswant@gmail.com]
8- * Algorithm : N/A
8+ * Algorithm : All Pair Shortest Path
99 * Platform : Codeforces
10- * Ref :
10+ * Ref : Time Complexity: O(N^3), Space Complexity: O(N^2)
1111 */
1212
13- public class A {
13+ class A {
1414
1515 private InputStream inputStream ;
1616 private OutputStream outputStream ;
@@ -19,10 +19,6 @@ public class A{
1919
2020 private final int BUFFER = 100005 ;
2121
22- private int auxInts [] = new int [BUFFER ];
23- private long auxLongs [] = new long [1 ];
24- private double auxDoubles [] = new double [1 ];
25- private char auxChars [] = new char [1 ];
2622 private final long mod = 1000000000 +7 ;
2723 private final int INF = Integer .MAX_VALUE ;
2824 private final long INF_L = Long .MAX_VALUE / 10 ;
@@ -43,31 +39,28 @@ public A(boolean stdIO)throws FileNotFoundException{
4339
4440 final int MAX_N = 100 ;
4541 long cost [][] = new long [MAX_N + 1 ][MAX_N + 1 ];
46- long w [][] = new long [MAX_N + 1 ][MAX_N + 1 ];
42+ long weight [][] = new long [MAX_N + 1 ][MAX_N + 1 ];
4743
48-
4944 void run ()throws Exception {
5045 int n = i ();
5146 int ans = 0 ;
52-
47+ initialize ();
5348 out .write ("" +ans +"\n " );
54-
5549 }
5650
57-
58- void clear (){
51+ void initialize (){
5952 for (int i = 1 ; i <= MAX_N ; i ++){
6053 for (int j = 1 ; j <= MAX_N ; j ++){
61- w [i ][j ] = INF_L ;
62- if (i ==j )w [i ][j ] = 0L ;
54+ weight [i ][j ] = INF_L ;
55+ if (i ==j )weight [i ][j ] = 0L ;
6356 }
6457 }
6558 }
6659
6760 void allPairShortestPath (int n ){
6861 for (int i = 1 ; i <= n ; i ++){
6962 for (int j = 1 ; j <= n ; j ++){
70- cost [i ][j ] = w [i ][j ];
63+ cost [i ][j ] = weight [i ][j ];
7164 }
7265 }
7366 // order matters: k->i->j
@@ -105,10 +98,10 @@ long pow(long a, long b, long mod){
10598 if (b == 0 )return 1 ;
10699 if (b == 1 )return a ;
107100 long ans = pow (a , b /2 , mod );
108- ans = (ans * ans );
101+ ans = mulMod (ans , ans , mod );
109102 if (ans >= mod )ans %= mod ;
110103
111- if (b % 2 == 1 )ans = ( a * ans );
104+ if (b % 2 == 1 )ans = mulMod ( a , ans , mod );
112105 if (ans >= mod )ans %= mod ;
113106
114107 return ans ;
@@ -135,46 +128,26 @@ int i()throws Exception{
135128 return in .nextInt ();
136129 }
137130
138- int [] is (int n )throws Exception {
139- for (int i =1 ; i <= n ;i ++)auxInts [i ] = in .nextInt ();
140- return auxInts ;
141- }
142-
143131 long l ()throws Exception {
144132 return in .nextLong ();
145133 }
146134
147- long [] ls (int n )throws Exception {
148- for (int i =1 ; i <= n ;i ++)auxLongs [i ] = in .nextLong ();
149- return auxLongs ;
150- }
151-
152135 double d ()throws Exception {
153136 return in .nextDouble ();
154137 }
155138
156- double [] ds (int n )throws Exception {
157- for (int i =1 ; i <= n ;i ++)auxDoubles [i ] = in .nextDouble ();
158- return auxDoubles ;
159- }
160-
161139 char c ()throws Exception {
162140 return in .nextCharacter ();
163141 }
164142
165- char [] cs (int n )throws Exception {
166- for (int i =1 ; i <= n ;i ++)auxChars [i ] = in .nextCharacter ();
167- return auxChars ;
168- }
169-
170143 String s ()throws Exception {
171144 return in .nextLine ();
172145 }
173146
174147 BigInteger bi ()throws Exception {
175148 return in .nextBigInteger ();
176149 }
177-
150+
178151 private void closeResources (){
179152 out .flush ();
180153 out .close ();
0 commit comments