結果
問題 | No.2871 Universal Serial Bus |
ユーザー |
|
提出日時 | 2024-09-06 21:27:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 744 ms |
コンパイル使用メモリ | 71,332 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-06 21:27:26 |
合計ジャッジ時間 | 1,441 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include<iostream>#include<iomanip>#include<cassert>using namespace std;int H,W;string S[20],T[20];int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cin>>H>>W;for(int i=0;i<H;i++)cin>>S[i];for(int i=0;i<H;i++)cin>>T[i];bool X=true,Y=true;for(int i=0;i<H;i++)for(int j=0;j<W;j++){if(S[i][j]==T[i][j])X=false;if(S[H-i-1][W-j-1]==T[i][j])Y=false;}if(!X&&!Y){cout<<-1<<endl;return 0;}long double ans=0;long double cur=1;for(int i=1;i<=50;i++){if(X){long double p=(long double)1/(1LL<<i-1);ans+=i*cur*(1-p);cur*=p;}swap(X,Y);}cout<<fixed<<setprecision(16)<<ans<<endl;}