結果

問題 No.3018 簡易版ページランク
ユーザー kokoa1046kokoa1046
提出日時 2018-01-31 10:41:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 758 ms / 2,000 ms
コード長 1,524 bytes
コンパイル時間 2,376 ms
コンパイル使用メモリ 75,144 KB
実行使用メモリ 65,628 KB
最終ジャッジ日時 2023-08-28 17:28:41
合計ジャッジ時間 10,757 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
55,976 KB
testcase_01 AC 147 ms
55,956 KB
testcase_02 AC 155 ms
56,192 KB
testcase_03 AC 158 ms
56,968 KB
testcase_04 AC 158 ms
56,336 KB
testcase_05 AC 171 ms
56,052 KB
testcase_06 AC 169 ms
56,308 KB
testcase_07 AC 186 ms
56,124 KB
testcase_08 AC 194 ms
56,272 KB
testcase_09 AC 208 ms
56,592 KB
testcase_10 AC 225 ms
60,724 KB
testcase_11 AC 219 ms
58,692 KB
testcase_12 AC 224 ms
58,252 KB
testcase_13 AC 259 ms
59,280 KB
testcase_14 AC 306 ms
61,828 KB
testcase_15 AC 281 ms
61,648 KB
testcase_16 AC 313 ms
61,744 KB
testcase_17 AC 323 ms
61,124 KB
testcase_18 AC 442 ms
63,288 KB
testcase_19 AC 502 ms
62,500 KB
testcase_20 AC 597 ms
65,628 KB
testcase_21 AC 619 ms
63,864 KB
testcase_22 AC 758 ms
65,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Map.Entry;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		ArrayList<HashMap<Integer, Double>> adj = new ArrayList<HashMap<Integer, Double>>();
		for(int i = 0; i < N; i++){ adj.add(new HashMap<Integer, Double>()); }
		
		for(int i = 0; i < M; i++){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final double c = sc.nextDouble();
			

			adj.get(a).put(b, c);
			
		}
		
		double[] out_sum = new double[N];
		for(int curr = 0; curr < N; curr++){
			for(final double denom : adj.get(curr).values()){
				out_sum[curr] += denom;
			}
		}
		
		double[] curr_rank = new double[N];
		for(int i = 0; i < N; i++){ curr_rank[i] = 10; }
		double[] next_rank = new double[N];
		
		for(int i = 0; i < 100; i++){
			Arrays.fill(next_rank, 0);
			
			for(int curr = 0; curr < N; curr++){
				for(final Entry<Integer, Double> entry : adj.get(curr).entrySet()){
					final int next = entry.getKey();
					final double mul = entry.getValue();
					
					next_rank[next] += curr_rank[curr] * mul / out_sum[curr];
				}
			}
			
			{
				//double[] tmp = curr_rank;
				curr_rank = next_rank.clone();
				//next_rank = curr_rank.clone();
			}
		}
		
		for(int i = 0; i < N; i++){
			System.out.printf("%.08f\n", curr_rank[i]);
		}

	}
}
0