結果

問題 No.298 話の伝達
ユーザー antaanta
提出日時 2015-11-07 00:28:24
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,897 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 76,924 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-11 14:44:06
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

struct S {
	int A, B;
	double C;
};

int main() {
	int N; int M;
	while(~scanf("%d%d", &N, &M)) {
		vector<S> rels(M);
		rep(i, M) {
			int A; int B; int C;
			scanf("%d%d%d", &A, &B, &C);
			S s{A, B, C / 100.};
			rels[i] = s;
		}
		if(M > 24) return 1;
		double ans = 0;
		rep(i, 1 << M) {
			double prob = 1;
			rep(j, M) {
				const S &s = rels[j];
				prob *= (i >> j & 1) ? s.C : 1 - s.C;
			}
			int reach = 1 << 0;
			rep(k, M) {
				int p = reach;
				rep(j, M) if(i >> j & 1) {
					const S &s = rels[j];
					if(reach >> s.A & 1)
						reach |= 1 << s.B;
				}
				if(reach == p || (reach >> (N - 1) & 1))
					break;
			}
			if(reach >> (N - 1) & 1)
				ans += prob;
		}
		printf("%.10f\n", ans);
	}
	return 0;
}
0