結果

問題 No.309 シャイな人たち (1)
ユーザー chocoruskchocorusk
提出日時 2019-12-29 03:19:13
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,014 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 111,256 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-20 13:38:26
合計ジャッジ時間 31,851 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,982 ms
4,384 KB
testcase_01 AC 3,914 ms
4,384 KB
testcase_02 AC 44 ms
4,380 KB
testcase_03 AC 2,888 ms
4,380 KB
testcase_04 AC 19 ms
4,380 KB
testcase_05 AC 490 ms
4,384 KB
testcase_06 AC 39 ms
4,384 KB
testcase_07 AC 144 ms
4,380 KB
testcase_08 AC 3,151 ms
4,380 KB
testcase_09 AC 3,882 ms
4,380 KB
testcase_10 TLE -
testcase_11 AC 3,852 ms
4,512 KB
testcase_12 AC 2,866 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int r, c; cin>>r>>c;
	double p[11][11]; int s[11][11]={};
	for(int i=0; i<r; i++) for(int j=0; j<c; j++) cin>>p[i][j];
	for(int i=0; i<r; i++) for(int j=0; j<c; j++) cin>>s[i][j];
	double dp[12][1<<11]={};
	dp[0][0]=1;
	double ans=0;
	double q[11][1<<11];
	for(int i=0; i<r; i++){
		for(int k=0; k<(1<<c); k++){
			q[i][k]=1;
			for(int l=0; l<c; l++){
				if(k&(1<<l)){
					q[i][k]*=p[i][l]/100;
				}else{
					q[i][k]*=(100-p[i][l])/100;
				}
			}
		}
	}
	for(int i=0; i<r; i++){
		for(int j=0; j<(1<<c); j++){
			if(dp[i][j]==0) continue;
			for(int k=0; k<(1<<c); k++){
				int cnt[11]={}, cntm=0;
				bool used[11]={};
				int que[30];
				int t=0, u=0, m=0;
				for(int l=0; l<c; l++){
					if(k&(1<<l)) cnt[l]=4-s[i][l];
					else{
						used[l]=1;
						continue;
					}
					if(j&(1<<l)) cnt[l]++;
					if(cnt[l]>=4){
						que[u]=l; u++;
						used[l]=1;
						m^=(1<<l);
						cntm++;
					}
				}
				while(t<u){
					int x=que[t]; t++;
					if(x>0 && !used[x-1] && cnt[x-1]>=2){
						cnt[x-1]++;
						if(cnt[x-1]>=4 && !used[x-1]){
							que[u]=x-1; u++;
							used[x-1]=1;
							cntm++;
							m^=(1<<(x-1));
						}
					}
					if(x<c-1 && !used[x+1] && cnt[x+1]>=2){
						cnt[x+1]++;
						if(cnt[x+1]>=4){
							que[u]=x+1; u++;
							used[x+1]=1;
							cntm++;
							m^=(1<<(x+1));
						}
					}
				}
				double myon=q[i][k]*dp[i][j];
				dp[i+1][m]+=myon;
				ans+=myon*cntm;
			}
		}
	}
	printf("%.9lf\n", ans);
	return 0;
}
0