結果

問題 No.309 シャイな人たち (1)
ユーザー yosupotyosupot
提出日時 2015-12-02 01:07:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,808 ms / 4,000 ms
コード長 1,703 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 69,232 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 08:30:22
合計ジャッジ時間 59,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,454 ms
4,348 KB
testcase_01 AC 3,808 ms
4,352 KB
testcase_02 AC 3,161 ms
4,356 KB
testcase_03 AC 3,728 ms
4,352 KB
testcase_04 AC 3,557 ms
4,348 KB
testcase_05 AC 3,534 ms
4,348 KB
testcase_06 AC 3,162 ms
4,352 KB
testcase_07 AC 3,294 ms
4,348 KB
testcase_08 AC 3,701 ms
4,352 KB
testcase_09 AC 3,709 ms
4,352 KB
testcase_10 AC 3,540 ms
4,352 KB
testcase_11 AC 3,469 ms
4,348 KB
testcase_12 AC 3,438 ms
4,352 KB
testcase_13 AC 2,944 ms
4,348 KB
testcase_14 AC 2,947 ms
4,352 KB
testcase_15 AC 3,164 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;
const int r = 11;
const int c = 11;
int main() {
	int rr, cc;
	cin >> rr >> cc;
	static double p[MN][MN];
	static int s[MN][MN];
	for (int i = 0; i < rr; i++) {
		for (int j = 0; j < cc; j++) {
			cin >> p[i][j];
			p[i][j] /= 100.0;
		}
	}
	for (int i = 0; i < rr; i++) {
		for (int j = 0; j < cc; j++) {
			cin >> s[i][j];
			s[i][j] = 4-s[i][j];
		}
	}

	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 (k & (1<<m)) u++;
					if (back) 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