結果

問題 No.298 話の伝達
ユーザー asi1024
提出日時 2015-11-12 21:46:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 732 bytes
コンパイル時間 1,246 ms
コンパイル使用メモリ 162,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-13 14:32:10
合計ジャッジ時間 2,674 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef long long ll;
typedef long double ld;

const ld eps = 1e-9, pi = acos(-1.0);

int A[256], B[256];
ld C[256];

int main() {
  int N, M; cin >> N >> M;
  REP(i,M) cin >> A[i] >> B[i] >> C[i];
  REP(i,M) C[i] /= 100;
  ld res = 0;
  for (int bit = (1 << (N-1)) + 1; bit < (1 << N); bit += 2) {
    vector<ld> p(N, 1);
    REP(i,M) if ((bit >> A[i]) & 1) p[B[i]] *= 1 - C[i];
    ld prod = 1;
    for (int i = 1; i < N; ++i) {
      if ((bit >> i) & 1) prod *= 1 - p[i];
      else prod *= p[i];
    }
    res += prod;
  }
  cout << setprecision(12) << fixed;
  cout << res << endl;
  return 0;
}
0