結果
| 問題 |
No.2871 Universal Serial Bus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-06 21:40:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,161 bytes |
| コンパイル時間 | 2,315 ms |
| コンパイル使用メモリ | 199,792 KB |
| 最終ジャッジ日時 | 2025-02-24 04:07:41 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int H,W; cin >> H >> W;
vector<string> S(H),T(H);
for(auto &s : S) cin >> s;
for(auto &t : T) cin >> t;
for(auto &s : S) for(auto &c : s) c ^= '.'^'#';
vector<string> S2(H,string(W,'.'));
for(int i=0; i<H; i++) for(int k=0; k<W; k++) S2.at(H-1-i).at(W-1-k) = S.at(i).at(k);
if(S != T){
swap(S,S2);
if(S == T){
double answer = 0,all = 1;
for(int i=1; i<=100; i+=2){
double now = 1.0-pow(0.5,i);
answer += all*now*(i+1);
all -= all*now;
}
cout << fixed << setprecision(20) << answer << endl;
}
else cout << "-1" << endl;
}
else if(S2 != T) cout << fixed << setprecision(20) << 3.5317401904617327 << endl;
else{
double answer = 0,all = 1;
for(int i=0; i<=100; i++){
double now = 1.0-pow(0.5,i);
answer += all*now*(i+1);
all -= all*now;
}
cout << fixed << setprecision(20) << answer << endl;
}
}