結果

問題 No.162 8020運動
ユーザー keikei
提出日時 2018-08-28 00:21:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,752 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 164,820 KB
実行使用メモリ 9,000 KB
最終ジャッジ日時 2023-09-19 09:35:37
合計ジャッジ時間 14,268 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,738 ms
9,000 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 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://yukicoder.me/problems/no/162>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

typedef long double ld;
ld memo[21][1<<14];
int A;
ld P[3];
ld rec(int a,int tooth){
    ld& ret = memo[a][tooth];
    if(!(ret < 0)) return ret;
    ret = 0;
    for(int t = 0; t < (1<<14);t++){
        if((tooth&t) != tooth) continue;
        ld Ptooth = 1;
        for(int b = 0; b < 14;b++){
            if(!((t>>b)&1)) continue;
            int cnt = 2;
            if(b == 0){
                cnt--;
                if(!((t>>1)&1)) cnt--;
            }else if(b == 13){
                cnt--;
                if(!((t>>12)&1)) cnt--;
            }else{
                if(!((t>>(b-1))&1)) cnt--;
                if(!((t>>(b+1))&1)) cnt--;
            }
            if((tooth>>b)&1) Ptooth *= (1-P[cnt]);
            else Ptooth *= P[cnt];
        }
        ret += (Ptooth*rec(a-1,t));
    }
    return ret;
}
ld solve(){
    fill(*memo,*memo+21*(1<<14),-1);
    ld res = 0;
    cin >> A; A = 80 - A;
    for(int i = 0; i < 3;i++){ cin >> P[i]; P[i]/=100;}
    for(int t = 0; t < (1<<14);t++)memo[0][t] = 0;
    memo[0][(1<<14)-1] = 1;
    for(int t = 0; t < (1<<14);t++) rec(A,t);
    for(int tup = 0; tup < (1<<14);tup++){
        int up = __builtin_popcount(tup);
        for(int tdown = 0; tdown < (1<<14);tdown++){
            int down = __builtin_popcount(tdown);
            res += (up+down)*memo[A][tup]*memo[A][tdown];
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12) << solve() << endl;
    return 0;
}
0