結果

問題 No.3018 簡易版ページランク
ユーザー ゆにぽけゆにぽけ
提出日時 2023-10-17 19:32:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,006 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 129,416 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 19:32:52
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
using namespace std;
int N,M;
vector<pair<int,int> >G[1000];
int C[1000];
long double dp[2][1000];
void solve()
{
	cin >> N >> M;
	for(int i = 0;i < M;i++)
	{
		int u,v,c;
		cin >> u >> v >> c;
		G[u].push_back(make_pair(v,c));
		C[u] += c;
	}
	int cur = 0;
	for(int i = 0;i < N;i++) dp[cur][i] = 10.0;
	for(int t = 0;t < 100;t++)
	{
		int nxt = 1-cur;
		for(int i = 0;i < N;i++) dp[nxt][i] = 0.0;
		for(int i = 0;i < N;i++)for(auto [j,c]:G[i]) dp[nxt][j] += dp[cur][i]*c/C[i];
		swap(cur,nxt);
	}

	cout << fixed << setprecision(16);
	for(int i = 0;i < N;i++) cout << dp[cur][i] << "\n";
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	//cin >> tt;
	while(tt--) solve();
}
0