結果
| 問題 |
No.2871 Universal Serial Bus
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-09-06 21:49:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,717 bytes |
| コンパイル時間 | 3,162 ms |
| コンパイル使用メモリ | 255,388 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-06 21:49:31 |
| 合計ジャッジ時間 | 3,765 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
namespace timer{
auto start=chrono::system_clock::now();
void snap(){
start=chrono::system_clock::now();
}
int get_ms(){
auto now=chrono::system_clock::now();
int ms=chrono::duration_cast<chrono::milliseconds>(now-start).count();
return ms;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll h,w;
cin >> h >> w;
vector<string> s(h),t(h);
rep(i,h) cin >> s[i];
rep(i,h) cin >> t[i];
vector<ll> v(2,true);
rep(i,h){
rep(j,w){
if(s[i][j]==t[i][j]) v[0]=false;
}
}
reverse(all(s));
rep(i,h) reverse(all(s[i]));
rep(i,h){
rep(j,w){
if(s[i][j]==t[i][j]) v[1]=false;
}
}
if(!v[0]&&!v[1]){
cout << "-1\n";
return 0;
}
vector<ld> dp(100,0);
dp[0]=1;
ld ans=0;
rep(i,99){
if(v[1-(i&1)]){
ld r=(ld)1-powl(2,-(i-1));
ans+=i*dp[i]*r;
dp[i+1]+=dp[i]*((ld)1-r);
}else{
dp[i+1]+=dp[i];
}
}
cout << fixed << setprecision(20) << ans << '\n';
}
FplusFplusF