結果
問題 | No.2871 Universal Serial Bus |
ユーザー |
|
提出日時 | 2024-09-07 12:06:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 887 bytes |
コンパイル時間 | 1,835 ms |
コンパイル使用メモリ | 196,044 KB |
最終ジャッジ日時 | 2025-02-24 05:07:46 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;template<class T> istream& operator >> (istream& is, vector<T>& vec) {for(T& x : vec) is >> x;return is;}int main(){ios::sync_with_stdio(false);cin.tie(0);int h, w;cin >> h >> w;vector<string> A(h), B(h);cin >> A >> B;int cnt1 = 0, cnt2 = 0;for(int y = 0; y < h; y++){for(int x = 0; x < w; x++){cnt1 += A[y][x] != B[y][x];cnt2 += A[h - 1 - y][w - 1 - x] != B[y][x];}}int S = (cnt1 == h * w) + (cnt2 == h * w) * 2;if(S == 0){cout << "-1\n";return 0;}double ans = 0, p = 1, div = 1;for(int i = 0; i < 100; i++){if(S >> (i & 1) & 1){ans += p * (1 - div) * (i + 1);p *= div;}div /= 2;}cout << fixed << setprecision(15) << ans << '\n';}