結果
問題 | No.309 シャイな人たち (1) |
ユーザー |
![]() |
提出日時 | 2015-12-02 00:28:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2,637 ms / 4,000 ms |
コード長 | 1,672 bytes |
コンパイル時間 | 1,472 ms |
コンパイル使用メモリ | 161,336 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-14 07:27:40 |
合計ジャッジ時間 | 21,276 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#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(dp[y][up]>1e-11) {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;}