結果
問題 |
No.309 シャイな人たち (1)
|
ユーザー |
![]() |
提出日時 | 2015-12-02 20:42:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,163 bytes |
コンパイル時間 | 1,609 ms |
コンパイル使用メモリ | 165,668 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 08:01:33 |
合計ジャッジ時間 | 2,123 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef complex<double> P; typedef pair<int,int> pii; #define REP(i,n) for(ll i=0;i<n;++i) #define REPR(i,n) for(ll i=1;i<n;++i) #define FOR(i,a,b) for(ll i=a;i<b;++i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() #define MOD (ll)(1e9+7) #define ADD(a,b) a=((a)+(b))%MOD #define FIX(a) ((a)%MOD+MOD)%MOD #define Real long double #define EPS (Real)(1e-10) bool cut(vector<Real> &vr,int from,int to,Real rate){ Real weight = vr[from]*rate; vr[to] += weight; vr[from] -= weight; if(weight > EPS && to == 4)return true; return false; } int main(){ int h,w; cin>>h>>w; int p[h][w],s[h][w]; REP(i,h)REP(j,w)cin>>p[i][j]; REP(i,h)REP(j,w)cin>>s[i][j]; Real result = 0.0; Real before[w]; vector< vector<Real> > now(w,vector<Real>(5)), tmp(w,vector<Real>(5)); vector<Real> top(w); REP(i,w)before[i]=0.0; REP(i,h){ // initialize REP(j,w){ // init REPR(k,5)now[j][k]=0.0; now[j][0]=1.0; // from S Real upp = (Real)p[i][j]/100.0; int uph = 4-s[i][j]; cut(now[j],0,uph,upp); // from before upp = before[j]; REPR(_k,5){ int k = 4-_k; cut(now[j],k,k+1,upp); } // for interacting phase before[j] = 0.0; top[j] = now[j][4]; now[j][4] = 0.0; } // interacting bool flag = true; while(flag){ flag = false; // toright REPR(j,w){ REPR(_k,5){ int k = 4-_k; cut(now[j],k,k+1,top[j-1]); } } // toleft REPR(_j,w){ int j = w-1-_j; REPR(_k,5){ int k = 4-_k; cut(now[j],k,k+1,top[j+1]); } } // copying REP(j,w){ before[j] += top[j]; top[j] = now[j][4]; now[j][4] = 0.0; if(top[j]>EPS)flag = true; } } REP(j,w){ result += before[j]; } } cout.precision(15); cout << fixed << result << endl; return 0; }