結果

問題 No.309 シャイな人たち (1)
ユーザー fumofumofunifumofumofuni
提出日時 2021-09-15 17:55:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,689 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 208,108 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-09-11 04:11:25
合計ジャッジ時間 13,946 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,899 ms
7,804 KB
testcase_01 TLE -
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<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={0,1,-1,0,1,1,-1,-1,0};
const ll dx[9]={1,0,0,-1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 
double dp[13][1<<11];
double prob[1<<11];
int main(){
    ll h,w;cin >> h >> w;
    vector<vector<double>> g(h,vector<double>(w));
    rep(i,h){
        rep(j,w)cin >> g[i][j],g[i][j]/=100;
    }
    vvl s(h,vl(w));
    rep(i,h)rep(j,w)cin >> s[i][j];
    rep(i,h)rep(j,1<<w)dp[i][j]=0;
    dp[0][0]=1;
    double ans=0;
    rep(i,h){
        rep(bit,1<<w)prob[bit]=1;
        rep(cit,1<<w){
            rep(j,w){
                if(cit>>j&1){
                    prob[cit]*=g[i][j];
                }
                else prob[cit]*=1.0-g[i][j];
            }
        }
        rep(bit,1<<w){
            if(dp[i][bit]==0)continue;
            rep(cit,1<<w){
                ll to=0;//実際に手を挙げている
                rep(j,w){
                    ll now=(cit>>j&1? 4-s[i][j]:0);
                    if(bit>>j&1)now++;
                    if(j&&(to>>(j-1)&1))now++;
                    if(to>>(j+1)&1)now++;
                    if(now>=4)to|=(1<<j);
                }
                per(j,w){
                    if(to>>j&1)continue;
                    ll now=(cit>>j&1? 4-s[i][j]:0);
                    if(bit>>j&1)now++;
                    if(j&&(to>>(j-1)&1))now++;
                    if(to>>(j+1)&1)now++;
                    if(now>=4)to|=(1<<j);
                }
                dp[i+1][to]+=dp[i][bit]*prob[cit];
                ans+=dp[i][bit]*prob[cit]*(__builtin_popcount(to));
                /*if(ndp[to]==-1)ndp[to]=(dp[bit]+__builtin_popcount(to))*prob;
                else ndp[to]+=(dp[bit]+__builtin_popcount(to))*prob;*/
            }
        }
    }
    CST(10);
    cout << ans << endl;
}   
0