結果

問題 No.162 8020運動
ユーザー parukiparuki
提出日時 2016-09-06 01:16:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 743 ms / 5,000 ms
コード長 1,924 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 172,204 KB
実行使用メモリ 63,692 KB
最終ジャッジ日時 2024-04-27 16:44:36
合計ジャッジ時間 22,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 571 ms
61,312 KB
testcase_01 AC 648 ms
63,436 KB
testcase_02 AC 694 ms
62,976 KB
testcase_03 AC 734 ms
63,488 KB
testcase_04 AC 734 ms
63,684 KB
testcase_05 AC 731 ms
63,616 KB
testcase_06 AC 725 ms
63,488 KB
testcase_07 AC 743 ms
63,488 KB
testcase_08 AC 737 ms
63,616 KB
testcase_09 AC 570 ms
61,184 KB
testcase_10 AC 699 ms
63,552 KB
testcase_11 AC 655 ms
62,464 KB
testcase_12 AC 605 ms
61,696 KB
testcase_13 AC 712 ms
63,488 KB
testcase_14 AC 583 ms
62,788 KB
testcase_15 AC 577 ms
61,312 KB
testcase_16 AC 626 ms
61,952 KB
testcase_17 AC 595 ms
61,440 KB
testcase_18 AC 722 ms
63,488 KB
testcase_19 AC 674 ms
62,848 KB
testcase_20 AC 699 ms
62,976 KB
testcase_21 AC 711 ms
63,232 KB
testcase_22 AC 690 ms
62,976 KB
testcase_23 AC 706 ms
63,692 KB
testcase_24 AC 700 ms
63,104 KB
testcase_25 AC 709 ms
63,556 KB
testcase_26 AC 565 ms
61,184 KB
testcase_27 AC 653 ms
62,336 KB
testcase_28 AC 724 ms
63,360 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){
#ifdef _MSC_VER
    return __popcnt(x);
#elif __GNUC__
    return __builtin_popcount(x);
#else
    assert(0);
#endif
}

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