結果
| 問題 |
No.2871 Universal Serial Bus
|
| コンテスト | |
| ユーザー |
n0ma_ru
|
| 提出日時 | 2024-09-07 00:36:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,287 bytes |
| コンパイル時間 | 2,213 ms |
| コンパイル使用メモリ | 197,464 KB |
| 最終ジャッジ日時 | 2025-02-24 05:04:42 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) v.begin(),v.end()
#define dbg(x) cerr << #x << ": " << (x) << endl;
template<class F, class S>
ostream& operator<<(ostream& os, pair<F,S>& p) {
os << '(' << p.first << ',' << p.second << ')';
return os;
}
template<class Iter>
void print(Iter beg, Iter end) {
for (Iter itr = beg; itr != end; ++itr) {
cerr << *itr << ' ';
}
cerr << '\n';
}
int h,w;
vector<string> s,t;
int main() {
cin >> h >> w;
s.resize(h); t.resize(h);
for (int i = 0; i < h; ++i) cin >> s[i];
for (int i = 0; i < h; ++i) cin >> t[i];
for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) s[i][j] = (s[i][j]=='#' ? '.' : '#');
bool f1 = (s == t);
reverse(ALL(s));
for (int i = 0; i < h; ++i) reverse(ALL(s[i]));
bool f2 = (s == t);
if (!f1 && !f2) {
cout << -1 << '\n';
return 0;
}
double base = 1;
double ans = 0;
for (int t = 1; t < 60; ++t) {
double p = 1.0 / (1LL << (t-1));
if (t % 2 == 1 && f1 || t % 2 == 0 && f2) {
// cerr << t << " " << base * (1-p) << '\n';
ans += t * base * (1-p);
base *= p;
}
}
cout << fixed << setprecision(20) << ans << '\n';
}
n0ma_ru