結果

問題 No.162 8020運動
ユーザー beetbeet
提出日時 2019-04-01 20:30:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,799 ms / 5,000 ms
コード長 1,497 bytes
コンパイル時間 3,014 ms
コンパイル使用メモリ 234,720 KB
実行使用メモリ 231,212 KB
最終ジャッジ日時 2023-08-17 12:01:38
合計ジャッジ時間 47,087 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 906 ms
230,988 KB
testcase_01 AC 1,305 ms
231,004 KB
testcase_02 AC 1,536 ms
230,992 KB
testcase_03 AC 1,752 ms
230,980 KB
testcase_04 AC 1,799 ms
230,960 KB
testcase_05 AC 1,763 ms
231,144 KB
testcase_06 AC 1,757 ms
231,020 KB
testcase_07 AC 1,764 ms
230,980 KB
testcase_08 AC 1,773 ms
230,916 KB
testcase_09 AC 905 ms
230,984 KB
testcase_10 AC 1,533 ms
231,088 KB
testcase_11 AC 1,310 ms
231,020 KB
testcase_12 AC 1,078 ms
231,184 KB
testcase_13 AC 1,763 ms
230,924 KB
testcase_14 AC 946 ms
230,984 KB
testcase_15 AC 947 ms
231,016 KB
testcase_16 AC 1,128 ms
230,920 KB
testcase_17 AC 991 ms
231,132 KB
testcase_18 AC 1,707 ms
230,980 KB
testcase_19 AC 1,485 ms
231,020 KB
testcase_20 AC 1,570 ms
230,980 KB
testcase_21 AC 1,602 ms
231,068 KB
testcase_22 AC 1,524 ms
231,088 KB
testcase_23 AC 1,569 ms
230,924 KB
testcase_24 AC 1,544 ms
231,008 KB
testcase_25 AC 1,631 ms
231,132 KB
testcase_26 AC 904 ms
231,028 KB
testcase_27 AC 1,353 ms
230,916 KB
testcase_28 AC 1,722 ms
231,212 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;


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T,typename U> 
using gmap = cc_hash_table<T, U, hash<T> >;

//INSERT ABOVE HERE
signed main(){
  using D = double;
  using M = gmap<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]];
    }
    
    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