結果

問題 No.298 話の伝達
ユーザー chocoruskchocorusk
提出日時 2019-05-26 10:16:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 192 ms / 5,000 ms
コード長 988 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 102,688 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 17:51:36
合計ジャッジ時間 2,168 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 45 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 50 ms
4,348 KB
testcase_12 AC 27 ms
4,348 KB
testcase_13 AC 64 ms
4,348 KB
testcase_14 AC 28 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 192 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 43 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 89 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, m;
vector<P> gr[22];
int main()
{
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int a, b, c; cin>>a>>b>>c;
        gr[b].push_back({a, c});
    }
    double ans=0;
    for(int i=(1<<(n-1)|1); i<(1<<n); i+=2){
        double p0=1;
        for(int j=1; j<n; j++){
            double p=1;
            for(auto q:gr[j]){
                if(i&(1<<q.first)) p*=(1.0-(double)q.second/100);
            }
            if(i&(1<<j)) p0*=(1-p);
            else p0*=p;
        }
        ans+=p0;
    }
    printf("%.7lf\n", ans);
    return 0;
}
0