結果
問題 |
No.2871 Universal Serial Bus
|
ユーザー |
|
提出日時 | 2024-09-06 21:43:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 1,852 ms |
コンパイル使用メモリ | 198,320 KB |
最終ジャッジ日時 | 2025-02-24 04:10:04 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; int main() { ll H,W; cin>>H>>W; vector<string> S(H),T(H); for(int i=0;i<H;i++)cin>>S[i]; bool A=1,B=1; for(int i=0;i<H;i++){ cin>>T[i]; for(int j=0;j<W;j++)if(T[i][j]==S[i][j])A=0; } for(int i=0;i<H;i++)reverse(S[i].begin(),S[i].end()); reverse(S.begin(),S.end()); for(int i=0;i<H;i++){ for(int j=0;j<W;j++)if(T[i][j]==S[i][j])B=0; } if(!A&&!B)cout<<-1<<endl; else if(A&&B){ double an=0; double d=1.0,u=1.0; for(int i=0;i<2e7;i++){ if(1){ an+=d*(1.0-u)*(i+1); d=d*(1.0-(1.0-u)); } u/=2.0; } cout<<fixed<<setprecision(15)<<an<<endl; } else if(A){ cout<<"3.5317401904617327"<<endl; } else{ cout<<"3.128936827211877"<<endl; } }