結果
問題 | No.2871 Universal Serial Bus |
ユーザー |
![]() |
提出日時 | 2024-09-07 00:36:39 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,287 bytes |
コンパイル時間 | 2,365 ms |
コンパイル使用メモリ | 206,152 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-07 00:36:43 |
合計ジャッジ時間 | 3,392 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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'; }