結果

問題 No.298 話の伝達
ユーザー koyumeishikoyumeishi
提出日時 2015-11-07 00:37:51
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 945 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 80,100 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-11 14:46:02
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

bool dfs(vector<vector<int>> &G, vector<bool> &visit, int pos){
	visit[pos] = true;
	if(pos == G.size()-1) return true;
	for(int to : G[pos]){
		if(visit[to]) continue;
		if(dfs(G,visit,to)) return true;
	}
	return false;
}

#include <cassert>

int main(){
	int n,m;
	cin >> n >> m;

	assert(m<16);
	
	vector<int> a(m),b(m),c(m);
	for(int i=0; i<m; i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	double ans = 0.0;
	for(int i=0; i<(1<<m); i++){
		double tmp = 1.0;
		vector<vector<int>> G(n);
		vector<bool> visit(n,false);
		for(int j=0; j<m; j++){
			if((i>>j)&1){
				tmp *= c[j]/100.0;
				G[a[j]].push_back(b[j]);
			}else{
				tmp *= 1.0 - c[j]/100.0;
			}
		}
		if(dfs(G,visit, 0)){
			ans += tmp;
		}
	}

	printf("%.12f\n", ans);

	return 0;
}
0