結果
問題 |
No.8018 簡易版ページランク
|
ユーザー |
|
提出日時 | 2016-09-13 10:41:12 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 534 ms / 2,000 ms |
コード長 | 1,381 bytes |
コンパイル時間 | 3,692 ms |
コンパイル使用メモリ | 79,100 KB |
実行使用メモリ | 57,688 KB |
最終ジャッジ日時 | 2024-11-17 04:45:17 |
合計ジャッジ時間 | 10,077 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
package yukicoder; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Q1191 { public static void main(String[] args) { new Q1191().solver(); } void solver() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); ArrayList<Edge>[] g = new ArrayList[n]; for (int i = 0; i < n; i++) { g[i] = new ArrayList<>(); } for (int i = 0; i < m; i++) { int src = sc.nextInt(); int dst = sc.nextInt(); int rate = sc.nextInt(); g[src].add(new Edge(src, dst, rate)); } for (int i = 0; i < n; i++) { double sum = 0; for (Edge e : g[i]) { sum += e.rate; } for (Edge e : g[i]) { e.rate /= sum; } } double[][] population = new double[2][n]; for (int i = 0; i < n; i++) { population[0][i] = 10; } for (int i = 0; i < 100; i++) { Arrays.fill(population[(i + 1) % 2], 0); for (int j = 0; j < n; j++) { for (Edge e : g[j]) { population[(i + 1) % 2][e.dst] += population[i % 2][e.src] * e.rate; } } } for (int i = 0; i < n; i++) { System.out.printf("%f\n", population[(99 + 1) % 2][i]); } } class Edge { int src; int dst; double rate; Edge(int src, int dst, double rate) { this.src = src; this.dst = dst; this.rate = rate; } } void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }