結果

問題 No.298 話の伝達
ユーザー yukiyuki
提出日時 2015-11-14 05:07:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,041 bytes
コンパイル時間 1,164 ms
コンパイル使用メモリ 145,328 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 17:40:27
合計ジャッジ時間 4,670 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

int N,M;
float rr[21][21];
int yes[21];

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> M;

  REP(i,M){
    int a,b,c;
    cin >> a >> b >> c;
    rr[a][b] = c / 100.0;
  }

  double ans = 0.0;

  for(int mask=0; mask<1<<N; mask++){
    REP(i,N){ yes[i] = (mask >> i) & 1; }
    if(yes[0] == 0 || yes[N-1] == 0) continue;

    double p = 1.0;
    FOR(i,1,N){
      double p_i = 1.0;
      REP(j,N){ if(yes[j] && rr[j][i]) p_i*=(1.0 - rr[j][i]); }
      if(yes[i]) p*=1.0-p_i;
      else p*=p_i;
    }
    ans += p;
  }

  cout << setprecision(10) << endl;
  cout << ans << endl;

  return 0;
}
0