結果

問題 No.309 シャイな人たち (1)
ユーザー fumofumofunifumofumofuni
提出日時 2021-09-15 22:17:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 4,000 ms
コード長 2,404 bytes
コンパイル時間 2,568 ms
コンパイル使用メモリ 207,896 KB
実行使用メモリ 4,552 KB
最終ジャッジ日時 2023-09-11 09:21:42
合計ジャッジ時間 3,780 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
4,444 KB
testcase_01 AC 17 ms
4,388 KB
testcase_02 AC 17 ms
4,492 KB
testcase_03 AC 17 ms
4,432 KB
testcase_04 AC 7 ms
4,492 KB
testcase_05 AC 11 ms
4,392 KB
testcase_06 AC 16 ms
4,388 KB
testcase_07 AC 16 ms
4,388 KB
testcase_08 AC 17 ms
4,392 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 18 ms
4,392 KB
testcase_11 AC 17 ms
4,552 KB
testcase_12 AC 17 ms
4,384 KB
testcase_13 AC 2 ms
4,392 KB
testcase_14 AC 3 ms
4,388 KB
testcase_15 AC 11 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

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[1<<12][13];//前の列のbit、連結してるリーチの個数
double ndp[1<<12][13];

int main(){
    rep(k,1<<12)rep(l,13)dp[k][l]=0;
    dp[0][0]=1;
    ll h,w;cin >> h >> w;
    vector<vector<double>> p(h,vector<double>(w+1));
    rep(i,h)rep(j,w){
        cin >> p[i][j+1];
        p[i][j+1]/=100;
    }
    vvl s(h,vl(w+1,4));
    rep(i,h){
        rep(j,w){
            cin >> s[i][j+1];
        }
    }
    w++;
    double ans=0;
    ll mask=(1<<w)-1;
    rep(i,h){
        rep(j,w){
            rep(bit,1<<w)rep(k,13)ndp[bit][k]=0;
            rep(bit,1<<w){
                rep(k,w+1){
                    if(dp[bit][k]==0)continue;
                    ll to=bit<<1&mask;
                    ndp[to][0]+=dp[bit][k]*(1.0-p[i][j]);
                    ll si=s[i][j]-(bit&1)-(bit>>(w-1));
                    if(si>1){
                        ndp[to][0]+=dp[bit][k]*p[i][j];
                    }
                    else if(si==1){
                        ndp[to][k+1]+=dp[bit][k]*p[i][j];
                    }
                    else{
                        ans+=dp[bit][k]*p[i][j]*(k+1);
                        to|=(1<<k+1)-1;
                        ndp[to][0]+=dp[bit][k]*p[i][j];
                    }
                }
            }
            swap(dp,ndp);
        }
    }
    CST(10);
    cout << ans << endl;
}   
0