結果
問題 | No.2871 Universal Serial Bus |
ユーザー |
![]() |
提出日時 | 2024-09-06 21:28:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 4,560 ms |
コンパイル使用メモリ | 255,340 KB |
最終ジャッジ日時 | 2025-02-24 04:01:02 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include <stdio.h>#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using mint = modint998244353;using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf32 1000000001#define Inf64 1000000000000000001bool check(vector<string> x,vector<string> y){rep(i,x.size()){rep(j,x[i].size()){if(x[i][j]==y[i][j])return false;}}return true;}int main(){int h,w;cin>>h>>w;vector<string> s(h),t(h);rep(i,h)cin>>s[i];rep(i,h)cin>>t[i];bool f0 = check(s,t);rep(i,h){reverse(t[i].begin(),t[i].end());}reverse(t.begin(),t.end());bool f1 = check(s,t);if(!f0&&!f1){cout<<-1<<endl;return 0;}double ans = 0,cp = 1;double inv2 = 1.0;rep(i,5000000){double p = 0;if(i%2==0&&f0)p = 1-inv2;if(i%2==1&&f1)p = 1-inv2;ans += cp*p*(i+1);cp *= 1-p;inv2 /= 2.0;}cout<<fixed<<setprecision(10)<<ans<<endl;return 0;}