結果

問題 No.2871 Universal Serial Bus
ユーザー SnowBeenDidingSnowBeenDiding
提出日時 2024-09-06 21:36:02
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,094 bytes
コンパイル時間 5,064 ms
コンパイル使用メモリ 311,012 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-06 21:36:09
合計ジャッジ時間 6,034 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;

typedef long long ll;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h), t(h);
    rep(i, 0, h) cin >> s[i];
    rep(i, 0, h) cin >> t[i];
    auto f = [&]() {
        rep(i, 0, h) rep(j, 0, w) {
            if (s[i][j] == '#' && t[i][j] == '#')
                return false;
        }
        return true;
    };
    bool ok1 = f();
    reverse(s.begin(), s.end());
    bool ok2 = f();
    if (!ok1 && !ok2) {
        cout << "-1" << endl;
        return 0;
    }
    double ans = 0;
    double sp = 0;
    rep(i, 1, 100) {
        double p = 1.0 - 1.0 / pow(2, i - 1);
        cerr << p << endl;
        if (i % 2 == 1 && ok1) {
            double x = (1.0 - sp) * p;
            ans += x * i;
            sp += x;
        }
        if (i % 2 == 0 && ok2) {
            double x = (1.0 - sp) * p;
            ans += x * i;
            sp += x;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}
0