結果
| 問題 |
No.2871 Universal Serial Bus
|
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2024-09-06 21:43:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,083 bytes |
| コンパイル時間 | 5,521 ms |
| コンパイル使用メモリ | 312,656 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-06 21:43:14 |
| 合計ジャッジ時間 | 6,257 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 |
ソースコード
#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());
rep(i, 0, h) reverse(s[i].begin(), s[i].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;
bool ok = false;
ok |= (i % 2 == 1 && ok1);
ok |= (i % 2 == 0 && ok2);
if (ok) {
double x = (1.0 - sp) * p;
ans += x * i;
sp += x;
}
}
cout << fixed << setprecision(10) << ans << endl;
}
SnowBeenDiding