結果

問題 No.309 シャイな人たち (1)
ユーザー yosupotyosupot
提出日時 2015-12-02 00:20:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,504 bytes
コンパイル時間 914 ms
コンパイル使用メモリ 73,204 KB
実行使用メモリ 12,192 KB
最終ジャッジ日時 2023-10-12 08:20:52
合計ジャッジ時間 11,478 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 int 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 k = 0; k < (1<<c); k++) {
			for (int l = 0; l < (1<<c); l++) {
				double pp = 1;
				static int u[MN];
				for (int m = 0; m < c; m++) {
					pp *= p[i][m];
					u[m] = 0;
					if (l & (1<<m)) u[m] = s[i][m];
					if (k & (1<<m)) u[m]++;
				}
				queue<int> q;
				for (int m = 0; m < c; m++) {
					if (u[m] >= 4) {
						q.push(m);
					}
				}
				int ll = 0;
				while (!q.empty()) {
					int m = q.front(); q.pop();
					if (ll & (1<<m)) continue;
					ll |= (1<<m);
					if (m > 0) {
						u[m-1]++;
						if (u[m-1] == 4) q.push(m-1);
					}
					if (m < c-1) {
						u[m+1]++;
						if (u[m+1] == 4) q.push(m+1);
					}
				}
				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