結果
| 問題 | No.298 話の伝達 |
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-11-07 00:37:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 945 bytes |
| 記録 | |
| コンパイル時間 | 702 ms |
| コンパイル使用メモリ | 80,556 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 13:26:28 |
| 合計ジャッジ時間 | 2,719 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 RE * 10 |
ソースコード
#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;
}
koyumeishi