結果

問題 No.162 8020運動
ユーザー beetbeet
提出日時 2019-04-01 20:28:44
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,171 ms / 5,000 ms
コード長 1,403 bytes
コンパイル時間 3,758 ms
コンパイル使用メモリ 212,256 KB
実行使用メモリ 194,172 KB
最終ジャッジ日時 2023-08-17 11:58:18
合計ジャッジ時間 73,257 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 974 ms
194,040 KB
testcase_01 AC 2,010 ms
193,956 KB
testcase_02 AC 2,575 ms
194,040 KB
testcase_03 AC 3,127 ms
193,960 KB
testcase_04 AC 3,134 ms
194,172 KB
testcase_05 AC 3,136 ms
193,964 KB
testcase_06 AC 3,148 ms
193,956 KB
testcase_07 AC 3,138 ms
194,036 KB
testcase_08 AC 3,171 ms
194,124 KB
testcase_09 AC 982 ms
193,956 KB
testcase_10 AC 2,578 ms
193,956 KB
testcase_11 AC 2,001 ms
193,988 KB
testcase_12 AC 1,430 ms
193,988 KB
testcase_13 AC 3,132 ms
194,064 KB
testcase_14 AC 1,085 ms
193,964 KB
testcase_15 AC 1,086 ms
193,972 KB
testcase_16 AC 1,542 ms
194,132 KB
testcase_17 AC 1,200 ms
194,132 KB
testcase_18 AC 3,032 ms
194,072 KB
testcase_19 AC 2,455 ms
193,992 KB
testcase_20 AC 2,685 ms
194,148 KB
testcase_21 AC 2,690 ms
193,996 KB
testcase_22 AC 2,577 ms
194,124 KB
testcase_23 AC 2,689 ms
194,036 KB
testcase_24 AC 2,648 ms
193,988 KB
testcase_25 AC 2,799 ms
194,000 KB
testcase_26 AC 976 ms
194,120 KB
testcase_27 AC 2,118 ms
194,032 KB
testcase_28 AC 3,042 ms
194,088 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