結果
| 問題 | No.3615 Ge Gusser |
| コンテスト | |
| ユーザー |
KEYBO
|
| 提出日時 | 2026-08-06 15:13:23 |
| 言語 | C++23(gnu拡張gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 739 ms / 3,000 ms |
| + 276µs | |
| コード長 | 1,634 bytes |
| 記録 | |
| コンパイル時間 | 5,257 ms |
| コンパイル使用メモリ | 391,780 KB |
| 実行使用メモリ | 86,144 KB |
| 最終ジャッジ日時 | 2026-08-06 15:13:38 |
| 合計ジャッジ時間 | 10,822 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サンプル | 0 % | AC * 3 |
| 小課題1 | 40 % | AC * 8 |
| 小課題2 | 40 % | AC * 15 |
| 小課題3 | 20 % | AC * 27 |
| 合計 | 2.5 * 100% = 250 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvc = vector<vc>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using mint = modint998244353;
using vm = vector<mint>;
int main() {
int N,M;
cin >> N >> M;
unordered_set<ll> b2;
ll p = 1;
for (int i = 0; i < 50; i++) {
b2.insert(p);
p *= 2;
}
vs S(N);
vl code(N, 0);
for (int i = 0; i < N; i++) {
cin >> S[i];
ll power = 1;
for (int j = 0; j < M; j++) {
if (S[i][j] == 'o') code[i] += power;
power *= 2;
}
}
vector<ld> dp((1 << N), 0);
vi cnt((1 << N), 0);
vb end((1 << N), false);
for (int i = 1; i < (1 << N); i++) {
ll res = -1,power = 1,now = 0;
for (int j = 0; j < N; j++) {
if ((i & power) > 0) {
if (res == -1) res = code[j];
else res = (res & code[j]);
now++;
}
power *= 2;
}
cnt[i] = now;
if (b2.count(res)) end[i] = true;
}
dp[0] = 1;
ld ans = 0;
for (int i = 1; i < (1 << N); i++) {
ll power = 1;
for (int j = 0; j < N; j++) {
if ((i & power) == 0) {
power *= 2;
continue;
}
if (!end[(i ^ power)]) dp[i] += dp[(i ^ power)]/ld(N - cnt[(i ^ power)]);
power *= 2;
}
if (end[i]) ans += dp[i]*cnt[i];
}
cout << fixed << setprecision(9) << ans << endl;
return 0;
}
KEYBO