結果

問題 No.2871 Universal Serial Bus
ユーザー GOTKAKOGOTKAKO
提出日時 2024-09-06 21:40:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 206,968 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-06 21:41:08
合計ジャッジ時間 2,956 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
}
0