結果

問題 No.3018 簡易版ページランク
ユーザー furafura
提出日時 2020-06-14 03:47:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 2,803 ms
コンパイル使用メモリ 205,200 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 14:47:37
合計ジャッジ時間 3,775 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class T> struct edge{
	int to;
	T wt;
	edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using weighted_graph=vector<vector<edge<T>>>;

template<class T>
void add_directed_edge(weighted_graph<T>& G,int u,int v,const T& wt){
	G[u].emplace_back(v,wt);
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	weighted_graph<double> G(n);
	rep(i,m){
		int u,v;
		double c; scanf("%d%d%lf",&u,&v,&c);
		add_directed_edge(G,u,v,c);
	}

	vector<double> curr(n,10),next(n);
	rep(t,100){
		fill(next.begin(),next.end(),0);
		rep(u,n){
			double sum=0;
			for(auto e:G[u]) sum+=e.wt;
			for(auto e:G[u]) next[e.to]+=(e.wt/sum)*curr[u];
		}
		copy(next.begin(),next.end(),curr.begin());
	}
	rep(u,n) printf("%.9f\n",curr[u]);

	return 0;
}
0