結果

問題 No.813 ユキちゃんの冒険
ユーザー beetbeet
提出日時 2019-04-12 21:47:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,388 bytes
コンパイル時間 2,625 ms
コンパイル使用メモリ 205,476 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 13:24:06
合計ジャッジ時間 3,554 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 7 ms
4,380 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 AC 19 ms
4,380 KB
testcase_05 AC 18 ms
4,380 KB
testcase_06 AC 9 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 13 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 8 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 14 ms
4,376 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 16 ms
4,380 KB
testcase_16 AC 17 ms
4,380 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 19 ms
4,380 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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;


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  using D = long double;
  D p,q;
  cin>>p>>q;
  
  auto dp=make_v<D>(3,n+2);
  fill_v<D>(dp,0);
  dp[1+1][1]=1;
  
  D ans=0;
  for(Int uku=0;uku<1000;uku++){
    auto nx=make_v<D>(3,n+2);
    fill_v<D>(nx,0);
    for(Int v=1;v<=n;v++){
      for(Int d=-1;d<=1;d+=2){
        D x=dp[1+d][v];
        if(v+d==0) ans+=x*q;
        if(0<v+d&&v+d<=n) nx[1+d][v+d]+=x*q;
        if(v-d==0) ans+=x*p;
        if(0<v-d&&v-d<=n) nx[1-d][v-d]+=x*p;
      }
    }
    swap(dp,nx);
  }
  
  cout<<ans<<endl;
  return 0;
}
0