結果

問題 No.298 話の伝達
ユーザー parukiparuki
提出日時 2016-04-20 08:18:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 395 ms / 5,000 ms
コード長 1,009 bytes
コンパイル時間 1,386 ms
コンパイル使用メモリ 159,996 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 03:50:03
合計ジャッジ時間 4,514 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 392 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,948 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 10 ms
6,940 KB
testcase_11 AC 390 ms
6,940 KB
testcase_12 AC 181 ms
6,944 KB
testcase_13 AC 395 ms
6,940 KB
testcase_14 AC 179 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 390 ms
6,944 KB
testcase_17 AC 5 ms
6,944 KB
testcase_18 AC 84 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 180 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rt return
#define FOR(i,j,k) for(int i=j; i<(int)k;++i)
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(){
    int N, M;
    double ans = 0, p, q, C[20][20] = {};
    cin >> N >> M;
    rep(i, M){
        int u, v, w;
        cin >> u >> v >> w;
        C[u][v] = w*0.01;
    }
    rep(S, 1 << N)if((S & 1) && (S >> (N - 1) & 1)){
        p = 1.0;
        FOR(v, 1, N){
            q = 1.0;
            rep(u, N)if(u != v && (S >> u & 1))q *= (1 - C[u][v]);
            if(S >> v & 1)p *= (1 - q);
            else p *= q;
        }
        ans += p;
    }
    printf("%0.20f\n", ans);
}
0