結果
問題 | No.813 ユキちゃんの冒険 |
ユーザー | beet |
提出日時 | 2019-04-12 21:47:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,388 bytes |
コンパイル時間 | 2,348 ms |
コンパイル使用メモリ | 199,584 KB |
最終ジャッジ日時 | 2025-01-07 01:44:53 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 WA * 1 |
ソースコード
#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; }