結果

問題 No.298 話の伝達
ユーザー mayoko_mayoko_
提出日時 2015-11-07 00:43:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,560 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 7,592 KB
最終ジャッジ日時 2023-10-11 14:46:41
合計ジャッジ時間 7,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXM = 30;
int A[MAXM], B[MAXM], C[MAXM];
bool vis[MAXM];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    if (M > 30) return 0;
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }
    double ans = 0;
    for (int s = 0; s < 1<<M; s++) {
        double tmp = 1;
        for (int i = 0; i < M; i++) {
            if ((s>>i)&1) tmp *= C[i]/100.;
            else tmp *= 1-C[i]/100.;
        }
        queue<int> que;
        memset(vis, false, sizeof(vis));
        que.push(0);
        while (!que.empty()) {
            int now = que.front();
            vis[now] = true;
            que.pop();
            for (int i = 0; i < M; i++) {
                if (now == A[i] && ((s>>i)&1)) if (!vis[B[i]]) {
                    que.push(B[i]);
                    vis[B[i]] = true;
                }
            }
        }
        if (vis[N-1]) ans += tmp;
    }
    printf("%.10lf\n", ans);
    return 0;
}
0