結果
問題 |
No.298 話の伝達
|
ユーザー |
|
提出日時 | 2015-11-14 05:12:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 447 ms / 5,000 ms |
コード長 | 1,042 bytes |
コンパイル時間 | 1,243 ms |
コンパイル使用メモリ | 159,672 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 16:40:58 |
合計ジャッジ時間 | 4,328 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> #define FOR(i,a,b) for (int i=(a) ;i<(b) ;i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0 ;i<(n) ;i++) #define RREP(i,n) for (int i=(n)-1;i>=0 ;i--) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() const int MOD = 1e9 + 7; const int INF = 1 << 29; const double EPS = 1e-10; int N,M; double rr[21][21]; int yes[21]; using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; REP(i,M){ int a,b,c; cin >> a >> b >> c; rr[a][b] = c / 100.0; } double ans = 0.0; for(int mask=0; mask<1<<N; mask++){ REP(i,N){ yes[i] = (mask >> i) & 1; } if(yes[0] == 0 || yes[N-1] == 0) continue; double p = 1.0; FOR(i,1,N){ double p_i = 1.0; REP(j,N){ if(yes[j] && rr[j][i]) p_i*=(1.0 - rr[j][i]); } if(yes[i]) p*=1.0-p_i; else p*=p_i; } ans += p; } cout << setprecision(12) << fixed; cout << ans << endl; return 0; }