結果

問題 No.309 シャイな人たち (1)
ユーザー chocoruskchocorusk
提出日時 2019-12-28 10:03:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,993 bytes
コンパイル時間 1,896 ms
コンパイル使用メモリ 110,844 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-19 20:47:02
合計ジャッジ時間 14,555 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int r, c; cin>>r>>c;
  double p[11][11]; int s[11][11];
  for(int i=0; i<r; i++) for(int j=0; j<c; j++) cin>>p[i][j];
  for(int i=0; i<r; i++) for(int j=0; j<c; j++) cin>>s[i][j];
  double dp[12][1<<11]={};
  dp[0][0]=1;
  double ans=0;
  for(int i=0; i<r; i++){
    for(int j=0; j<(1<<c); j++){
      if(dp[i][j]==0) continue;
      for(int k=0; k<(1<<c); k++){
        double pp=1;
        for(int l=0; l<c; l++){
          if(k&(1<<l)){
            pp*=p[i][l]/100;
          }else{
            pp*=(100-p[i][l])/100;
          }
        }
        int cnt[11]={};
        bool used[11]={};
        int que[30];
        int t=0, u=0;
        for(int l=0; l<c; l++){
          if(k&(1<<l)) cnt[l]=4-s[i][l];
          if(j&(1<<l)) cnt[l]++;
          if(cnt[l]>=4){
            que[u]=l; u++;
            used[l]=1;
          }
        }
        while(t<u){
          int x=que[t]; t++;
          if(x>0){
            cnt[x-1]++;
            if(cnt[x-1]>=4 && !used[x-1]){
              que[u]=x-1; u++;
              used[x-1]=1;
            }
          }
          if(x<c-1){
            cnt[x+1]++;
            if(cnt[x+1]>=4 && !used[x+1]){
              que[u]=x+1; u++;
              used[x+1]=1;
            }
          }
        }
        int m=0;
        for(int l=0; l<c; l++) if(used[l]) m^=(1<<l);
        dp[i+1][m]+=pp*dp[i][j];
        ans+=pp*dp[i][j]*popcount(m);
      }
    }
  }
  printf("%.9lf\n", ans);
	return 0;
}
0