結果

問題 No.298 話の伝達
ユーザー koyoprokoyopro
提出日時 2015-11-06 23:05:33
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 604 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 153,912 KB
実行使用メモリ 4,536 KB
最終ジャッジ日時 2023-10-11 14:50:46
合計ジャッジ時間 3,011 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
struct P { int x, y; P(){}; P(int _x, int _y): x(_x), y(_y){}; };

int N,M,A,B,C;
map<int, vector<P> > MAP;
double dfs(int n) {
    if (n == 0) return 1.0;
    double fail = 1.0;
    for (auto&& p: MAP[n]) {
        fail *= 1.0 - dfs(p.x) * p.y / 100.0;
    }
    return 1 - fail;
}
signed main()
{
    cin >> N >> M;
    vector<double> Q(N, 0.0);
    Q[0] = 1.0;
    REP(i,M) {
        cin >> A >> B >> C;
        P p = P(A, C);
        MAP[B].push_back(p);
    }
    printf("%.14f\n", dfs(N-1));
    return 0;
}
0