結果

問題 No.162 8020運動
ユーザー parukiparuki
提出日時 2016-09-06 01:05:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 846 ms / 5,000 ms
コード長 2,077 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 173,724 KB
実行使用メモリ 63,684 KB
最終ジャッジ日時 2024-04-27 16:43:17
合計ジャッジ時間 25,859 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 667 ms
61,184 KB
testcase_01 AC 752 ms
62,336 KB
testcase_02 AC 796 ms
62,976 KB
testcase_03 AC 846 ms
63,488 KB
testcase_04 AC 841 ms
63,564 KB
testcase_05 AC 840 ms
63,432 KB
testcase_06 AC 843 ms
63,556 KB
testcase_07 AC 841 ms
63,556 KB
testcase_08 AC 842 ms
63,684 KB
testcase_09 AC 671 ms
61,184 KB
testcase_10 AC 799 ms
62,976 KB
testcase_11 AC 750 ms
62,208 KB
testcase_12 AC 703 ms
61,696 KB
testcase_13 AC 842 ms
63,556 KB
testcase_14 AC 676 ms
61,440 KB
testcase_15 AC 676 ms
61,184 KB
testcase_16 AC 716 ms
61,824 KB
testcase_17 AC 684 ms
61,312 KB
testcase_18 AC 833 ms
63,556 KB
testcase_19 AC 785 ms
62,848 KB
testcase_20 AC 805 ms
62,976 KB
testcase_21 AC 804 ms
62,976 KB
testcase_22 AC 797 ms
62,976 KB
testcase_23 AC 805 ms
63,104 KB
testcase_24 AC 797 ms
63,104 KB
testcase_25 AC 815 ms
63,104 KB
testcase_26 AC 668 ms
61,312 KB
testcase_27 AC 760 ms
62,336 KB
testcase_28 AC 830 ms
63,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int bitcnt(unsigned int x){
    x = (x & 0x55555555) + (x >> 1 & 0x55555555);
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
    x = (x & 0x00ff00ff) + (x >> 8 & 0x00ff00ff);
    x = (x & 0x0000ffff) + (x >> 16 & 0x0000ffff);
    return (int)x;
}

const int N = 14;
vi to[1 << N];
vector<double> pr[1 << N];
double dp[21][1 << N];

int main(){
    int A;
    cin >> A;
    int Y = 80 - A;
    double P0, P1, P2;
    cin >> P0 >> P1 >> P2;
    P0 *= 0.01;
    P1 *= 0.01;
    P2 *= 0.01;
    rep(S, 1 << N){
        bitset<N> b(S);
        FOR(nS, S, 1 << N)if((S&nS)==S){

            bitset<N> nb(nS);
            double p = 1;
            rep(i, N){
                if(b[i])continue;
                if((i == 0||b[i-1]) && (i==N-1 || b[i+1])){
                    if(nb[i])p *= P0;
                    else p *= 1.00 - P0;
                } else if((i == 0 || b[i - 1]) || (i == N - 1 || b[i + 1])){
                    if(nb[i])p *= P1;
                    else p *= 1.00 - P1;
                } else{
                    if(nb[i])p *= P2;
                    else p *= 1.00 - P2;
                }
            }
            to[S].push_back(nS);
            pr[S].push_back(p);
        }
    }

    dp[0][0] = 1;
    rep(y, Y)rep(S, 1 << N){
        rep(i, sz(to[S])){
            int nS = to[S][i];
            double p = pr[S][i];
            dp[y + 1][nS] += dp[y][S] * p;
        }
    }

    double ans = 0;
    rep(S, 1 << N)ans += (N-bitcnt(S))*dp[Y][S];
    cout << setprecision(20) << ans*2 << endl;
}
0