結果
問題 | No.2871 Universal Serial Bus |
ユーザー |
![]() |
提出日時 | 2024-09-06 21:37:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,471 bytes |
コンパイル時間 | 3,092 ms |
コンパイル使用メモリ | 253,504 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-06 21:38:19 |
合計ジャッジ時間 | 16,700 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 4 WA * 14 |
ソースコード
#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;}mt19937 mt;inline double rand_double(){ //[0.0,1.0]return (double)mt()/(double)mt19937::max();}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;}ll sum=0;rep(_,1e7){ll now=1;while(true){if(v[1-(now&1)]&&rand_double()<1-pow(2,-(now-1))) break;now++;}sum+=now;}cout << fixed << setprecision(10) << (ld)sum/(ld)1e7 << '\n';}