結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
56,412 KB
testcase_01 AC 133 ms
56,096 KB
testcase_02 AC 140 ms
56,320 KB
testcase_03 AC 145 ms
56,612 KB
testcase_04 AC 148 ms
56,800 KB
testcase_05 AC 157 ms
56,480 KB
testcase_06 AC 159 ms
56,100 KB
testcase_07 AC 178 ms
56,508 KB
testcase_08 AC 178 ms
56,952 KB
testcase_09 AC 190 ms
56,476 KB
testcase_10 AC 227 ms
59,536 KB
testcase_11 AC 234 ms
59,012 KB
testcase_12 AC 217 ms
59,000 KB
testcase_13 AC 266 ms
59,568 KB
testcase_14 AC 310 ms
61,236 KB
testcase_15 AC 278 ms
59,896 KB
testcase_16 AC 311 ms
61,704 KB
testcase_17 AC 329 ms
61,840 KB
testcase_18 AC 437 ms
64,216 KB
testcase_19 AC 486 ms
63,340 KB
testcase_20 AC 562 ms
63,016 KB
testcase_21 AC 618 ms
65,560 KB
testcase_22 AC 751 ms
65,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
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;
				next_rank = tmp;
			}
		}
		
		for(int i = 0; i < N; i++){
			System.out.printf("%.08f\n", curr_rank[i]);
		}

	}
}
0