結果

問題 No.309 シャイな人たち (1)
ユーザー rickythetarickytheta
提出日時 2015-12-02 20:42:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,163 bytes
コンパイル時間 1,853 ms
コンパイル使用メモリ 151,724 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 09:03:10
合計ジャッジ時間 2,161 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0