結果

問題 No.309 シャイな人たち (1)
ユーザー 👑 kmjpkmjp
提出日時 2015-12-02 02:55:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,676 bytes
コンパイル時間 1,313 ms
コンパイル使用メモリ 146,884 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-12 08:49:18
合計ジャッジ時間 22,319 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2,488 ms
4,372 KB
testcase_02 AC 81 ms
4,368 KB
testcase_03 AC 1,795 ms
4,368 KB
testcase_04 AC 24 ms
4,368 KB
testcase_05 AC 320 ms
4,372 KB
testcase_06 AC 58 ms
4,368 KB
testcase_07 AC 143 ms
4,368 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,368 KB
testcase_14 AC 1 ms
4,368 KB
testcase_15 AC 11 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
double P[101][101];
int S[101][101];

double dp[13][1<<11];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) FOR(x,W) cin>>r, P[y][x] = r/100.0;
	FOR(y,H) FOR(x,W) cin>>S[y][x];
	
	double ret=0;
	dp[0][0]=1;
	FOR(y,H) {
		for(int cur=0;cur<1<<W;cur++) {
			double pat=1;
			int hand=0;
			FOR(x,W) {
				if(cur&(1<<x)) {
					pat *= P[y][x];
					if(S[y][x]==0) hand |= 1<<(x+1);
				}
				else pat *= 1-P[y][x];
			}
			for(int up=0;up<1<<W;up++) if(pat*dp[y][up]>1e-13) {
				int hand2=hand;
				FOR(x,W) if(cur&(1<<x)) {
					int p=4-S[y][x];
					if(hand2&(1<<x)) p++;
					if(hand2&(1<<(x+2))) p++;
					if(up&(1<<x)) p++;
					if(p>=4) hand2 |= 1<<(x+1);
				}
				for(x=W-1;x>=0;x--) if(cur&(1<<x)) {
					int p=4-S[y][x];
					if(hand2&(1<<x)) p++;
					if(hand2&(1<<(x+2))) p++;
					if(up&(1<<x)) p++;
					if(p>=4) hand2 |= 1<<(x+1);
				}
				
				hand2 >>=1;
				ret += pat*dp[y][up]*__builtin_popcount(hand2);
				dp[y+1][hand2] += pat*dp[y][up];
			}
		}
	}
	
	_P("%.12lf\n",ret);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0