結果

問題 No.298 話の伝達
ユーザー asi1024asi1024
提出日時 2015-11-12 21:46:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 195 ms / 5,000 ms
コード長 732 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 146,740 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 15:44:52
合計ジャッジ時間 3,078 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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