結果

問題 No.309 シャイな人たち (1)
ユーザー tjaketjake
提出日時 2015-12-02 16:34:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,476 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 75,788 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-10-12 08:59:57
合計ジャッジ時間 18,591 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 13
#define N2 1<<13

int bit_count(int v) {
  int cnt = 0;
  for(;v!=0;v&=v-1) ++cnt;
  return cnt;
}

int main() {
  int r, c;
  cin >> r >> c;
  int p[N][N], s[N][N], bit[N2];
  double dp[N][N2], dpb[N][N];
  rep(i, r) rep(j, c) cin >> p[i][j];
  rep(i, r) rep(j, c) cin >> s[i][j];
  rep(i, r+1) rep(j, (1<<c)) dp[i][j] = 0.0;
  rep(i, r) rep(j, c) dpb[i][j] = 0.0;

  rep(i, (1<<c)) bit[i] = bit_count(i);

  dp[0][0] = 1.0;
  double ans = 0.0;
  rep(i, r) {
    rep(S, (1<<c)) {
      if(dp[i][S] == 0.0) {
        continue;
      }
      rep(T, (1<<c)) {
        double res = dp[i][S];
        rep(j, c) {
          int x = (S>>j)&1, y = (T>>(j-1))&1, z = (T>>(j+1))&1;
          if(x+y+z >= s[i][j]) {
            if((T>>j)&1) {
              res *= (double)p[i][j]/100.0;
            } else {
              res *= (double)(100-p[i][j])/100.0;
            }
          } else {
            if((T>>j)&1) {
              res = 0.0;
              break;
            }
          }
        }
        dp[i+1][T] += res;
      }
    }
    rep(T, (1<<c)) {
      ans += dp[i+1][T] * bit[T];
    }
  }
  printf("%.10f\n", ans);
  return 0;
}
0