結果
問題 |
No.2871 Universal Serial Bus
|
ユーザー |
![]() |
提出日時 | 2024-09-06 21:36:02 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 15 WA * 3 |
ソースコード
#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; }