結果

問題 No.162 8020運動
ユーザー beetbeet
提出日時 2019-04-01 20:28:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,238 ms / 5,000 ms
コード長 1,403 bytes
コンパイル時間 2,363 ms
コンパイル使用メモリ 214,984 KB
実行使用メモリ 194,432 KB
最終ジャッジ日時 2024-05-04 18:41:44
合計ジャッジ時間 73,673 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 982 ms
194,304 KB
testcase_01 AC 2,030 ms
194,176 KB
testcase_02 AC 2,613 ms
194,304 KB
testcase_03 AC 3,190 ms
194,304 KB
testcase_04 AC 3,195 ms
194,304 KB
testcase_05 AC 3,238 ms
194,176 KB
testcase_06 AC 3,189 ms
194,304 KB
testcase_07 AC 3,201 ms
194,432 KB
testcase_08 AC 3,193 ms
194,304 KB
testcase_09 AC 988 ms
194,304 KB
testcase_10 AC 2,614 ms
194,304 KB
testcase_11 AC 2,030 ms
194,176 KB
testcase_12 AC 1,443 ms
194,176 KB
testcase_13 AC 3,193 ms
194,304 KB
testcase_14 AC 1,095 ms
194,304 KB
testcase_15 AC 1,100 ms
194,304 KB
testcase_16 AC 1,566 ms
194,304 KB
testcase_17 AC 1,213 ms
194,304 KB
testcase_18 AC 3,096 ms
194,304 KB
testcase_19 AC 2,496 ms
194,304 KB
testcase_20 AC 2,726 ms
194,304 KB
testcase_21 AC 2,724 ms
194,432 KB
testcase_22 AC 2,604 ms
194,304 KB
testcase_23 AC 2,741 ms
194,304 KB
testcase_24 AC 2,608 ms
194,432 KB
testcase_25 AC 2,840 ms
194,304 KB
testcase_26 AC 981 ms
194,304 KB
testcase_27 AC 2,145 ms
194,304 KB
testcase_28 AC 3,079 ms
194,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  using D = double;
  using M = unordered_map<int, D>;
  int a;
  cin>>a;
  a=80-a;
  
  D p[3];
  for(int i=0;i<3;i++) cin>>p[i],p[i]/=100;

  const int t=14;
  int s=1<<t;
  
  vector<M> co(s);

  vector<vector<int> > vs(s,vector<int>(t+2));
  for(int b=0;b<s;b++)
    for(int i=0;i<t;i++)
      vs[b][i+1]=(b>>i)&1;
  
  for(int b=0;b<s;b++){
    vector<D> po(t);
    for(int i=0;i<t;i++){
      if((~b>>i)&1) continue;
      po[i]=p[vs[b][i]+vs[b][i+2]];
    }
    co[b].reserve(1<<__builtin_popcount(b));
    
    for(int nb=b;nb;nb=(nb-1)&b){
      D &res=co[b][nb];
      res=1.0;      
      for(int i=0;i<t;i++){
        if((~b>>i)&1) continue;
        if((~nb>>i)&1) res*=po[i];
        else res*=1.0-po[i];
      }
    }
  }
  
  vector<D> dp(s,0);
  dp[s-1]=1.0;
  
  for(int i=0;i<a;i++){
    vector<D> nx(s,0);
    for(int b=0;b<s;b++)
      for(int nb=b;nb;nb=(nb-1)&b)
        nx[nb]+=dp[b]*co[b][nb];
    swap(dp,nx);
  }  
  
  D ans=0;
  for(int b=0;b<s;b++)
    ans+=__builtin_popcount(b)*dp[b];

  cout<<ans*2<<endl;
  return 0;
}
0