結果

問題 No.3018 簡易版ページランク
ユーザー ttkkggwwttkkggww
提出日時 2022-03-03 03:24:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 4,445 ms
コンパイル使用メモリ 263,580 KB
実行使用メモリ 4,740 KB
最終ジャッジ日時 2023-09-23 17:14:23
合計ジャッジ時間 5,720 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 4 ms
4,436 KB
testcase_19 AC 4 ms
4,524 KB
testcase_20 AC 5 ms
4,524 KB
testcase_21 AC 6 ms
4,556 KB
testcase_22 AC 9 ms
4,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;

double dp[101][1000];
int n,m;
vector<vector<pair<int,double>>> G;

void solve(){
	for(int i = 0;i<n;i++){
		dp[0][i] = 10;
	}
	for(int i =0;i<100;i++){
		for(int j = 0;j<n;j++){
			double sum = 0;
			for(auto &[to,w]:G[j]){
				sum += w;
			}
			for(auto &[to,w]:G[j]){
				dp[i+1][to] += dp[i][j]*w/sum;
			}
		}
	}
	for(int i = 0;i<n;i++){
		printf("%.10lf\n",dp[100][i]);
	}
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	G.resize(n);
	for(int i = 0 ;i<m;i++){
		int a,b;
		double d;
		cin >> a >> b >> d;
		G[a].emplace_back(b,d);
	}
	solve();
}
0