結果

問題 No.3615 Ge Gusser
コンテスト
ユーザー tau1235
提出日時 2026-08-06 15:19:53
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 820 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,710 ms
コンパイル使用メモリ 335,560 KB
実行使用メモリ 69,248 KB
最終ジャッジ日時 2026-08-06 15:20:34
合計ジャッジ時間 8,134 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サンプル 0 % AC * 3
小課題1 40 % AC * 8
小課題2 40 % AC * 12 WA * 3
小課題3 20 % AC * 20 WA * 7
合計 2.5 * 40% = 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;

void solve(){
  using ull=unsigned long long;
  int n,m;
  cin>>n>>m;
  vector<ull> a(n);
  vector<ull> b(1<<n);
  for (int i=0;i<n;i++){
    string s;
    cin>>s;
    for (int j=0;j<m;j++){
      a[i]+=(1LL<<j)*(s[j]=='o');
    }
    b[1<<i]=a[i];
  }
  b[0]=(1LL<<m)-1;
  vector<double> dp(1<<n);
  dp[0]=1;
  double ans=0;
  for (int bit=0;bit<1<<n;bit++){
    ull mb=bit&(-bit);
    if (bit) b[bit]=b[bit-mb]&b[mb];
    if (__builtin_popcount(b[bit])==1){
      ans+=dp[bit]*__builtin_popcount(bit);
      continue;
    }
    int p=n-__builtin_popcount(bit);
    for (int i=0;i<n;i++){
      if (bit>>i&1) ;
      else dp[bit+(1<<i)]+=dp[bit]/p;
    }
  }
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

int main(){
  int t=1;
  //cin>>t;
  while (t--) solve();
}
0