結果
問題 | No.2871 Universal Serial Bus |
ユーザー |
![]() |
提出日時 | 2024-09-07 00:43:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 915 bytes |
コンパイル時間 | 2,107 ms |
コンパイル使用メモリ | 198,656 KB |
最終ジャッジ日時 | 2025-02-24 05:04:56 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 WA * 4 |
ソースコード
#include <bits/stdc++.h>using namespace std;void fast_io() {ios_base::sync_with_stdio(false);cin.tie(nullptr);}int main() {fast_io();int h, w;cin >> h >> w;vector<string> s(h), t(h);for (int i = 0; i < h; i++) {cin >> s[i];}for (int i = 0; i < h; i++) {cin >> t[i];}vector<string> s_rot(h, string(w, '.'));for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {s_rot[h - 1 - i][w - 1 - j] = s[i][j];}}bool ok[2] = {true, true};for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {if (s[i][j] == t[i][j]) {ok[0] = false;}if (s_rot[i][j] == t[i][j]) {ok[1] = false;}}}long double ans = 0;long double prob = 1.0;int M = 1e6;for (int i = 0; i < M; i++) {if (ok[i % 2]) {long double p = powl(2, -i);ans += (i + 1) * prob * (1.0 - p);prob *= p;}}cout << fixed << setprecision(16) << ans << endl;}