結果
| 問題 | No.309 シャイな人たち (1) |
| コンテスト | |
| ユーザー |
👑 kmjp
|
| 提出日時 | 2015-12-02 00:17:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,569 bytes |
| 記録 | |
| コンパイル時間 | 1,293 ms |
| コンパイル使用メモリ | 160,668 KB |
| 実行使用メモリ | 20,672 KB |
| 最終ジャッジ日時 | 2024-09-14 07:23:42 |
| 合計ジャッジ時間 | 11,747 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int H,W;
double P[101][101];
int S[101][101];
double dp[13][1<<11][144];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>H>>W;
FOR(y,H) FOR(x,W) cin>>r, P[y][x] = r/100.0;
FOR(y,H) FOR(x,W) cin>>S[y][x];
dp[0][0][0]=1;
FOR(y,H) {
for(int up=0;up<1<<W;up++) {
for(int cur=0;cur<1<<W;cur++) {
double pat=1;
int po[15]={0};
int hand=0;
FOR(x,W) {
if(cur&(1<<x)) {
pat *= P[y][x];
if(S[y][x]==0) hand |= 1<<(x+1);
}
else pat *= 1-P[y][x];
}
FOR(r,W) {
FOR(x,W) if(cur&(1<<x)) {
int p=4-S[y][x];
if(hand&(1<<x)) p++;
if(hand&(1<<(x+2))) p++;
if(up&(1<<x)) p++;
if(p>=4) hand |= 1<<(x+1);
}
}
hand >>=1;
FOR(x,130) {
dp[y+1][hand][x+__builtin_popcount(hand)] += pat*dp[y][up][x];
}
}
}
}
double ret=0;
FOR(x,130) {
FOR(y,1<<W) ret += dp[H][y][x]*x;
}
_P("%.12lf\n",ret);
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
kmjp