結果

問題 No.309 シャイな人たち (1)
ユーザー yosupotyosupot
提出日時 2015-12-02 00:45:41
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,658 bytes
コンパイル時間 1,832 ms
コンパイル使用メモリ 69,044 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 08:28:25
合計ジャッジ時間 50,731 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,856 ms
4,352 KB
testcase_01 TLE -
testcase_02 AC 3,501 ms
4,348 KB
testcase_03 TLE -
testcase_04 AC 50 ms
4,352 KB
testcase_05 AC 792 ms
4,348 KB
testcase_06 AC 3,517 ms
4,352 KB
testcase_07 AC 3,648 ms
4,348 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 3,922 ms
4,348 KB
testcase_12 AC 3,892 ms
4,356 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 712 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cassert>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


const int MN = 11;

int main() {
	int r, c;
	cin >> r >> c;
	static double p[MN][MN];
	static uint s[MN][MN];
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> p[i][j];
			p[i][j] /= 100.0;
		}
	}
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> s[i][j];
			s[i][j] = 4-s[i][j];
		}
	}

	static double dp1[1<<MN], dp2[1<<MN];
	double sm = 0;
	dp1[0] = 1.0;
	for (int i = 0; i < r; i++) {
		fill_n(dp2, 1<<MN, 0.0);
		for (int l = 0; l < (1<<c); l++) {
			double pp = 1;
			for (int m = 0; m < c; m++) {
				if (l & (1<<m)) {
					pp *= p[i][m];
				} else {
					pp *= 1.0-p[i][m];
				}
			}
			for (int k = 0; k < (1<<c); k++) {
				int ll = 0;
				bool back = false;
				for (int m = 0; m < c; m++) {
					int u = 0;
					if (l & (1<<m)) u = s[i][m];
					if (back) u++;
					if (k & (1<<m)) u++;
					if (u >= 4) {
						ll |= (1<<m);
						back = true;
					} else {
						back = false;
					}
				}
				back = false;
				for (int m = c-1; m >= 0; m--) {
					int u = 0;
					if (l & (1<<m)) u = s[i][m];
					if (back) u++;
					if (k & (1<<m)) u++;
					if (m && (ll & (1<<(m-1)))) u++;
					if (u >= 4 || (ll & (1<<m))) {
						ll |= (1<<m);
						back = true;
					} else {
						back = false;
					}
				}
				dp2[ll] += dp1[k]*pp;
			}
		}
		for (int j = 0; j < (1<<c); j++) {
			dp1[j] = dp2[j];
			sm += dp2[j] * __builtin_popcount(j);
		}

	}
	printf("%.20lf\n", sm);
	return 0;
}
0