結果

問題 No.2871 Universal Serial Bus
ユーザー yuusaan
提出日時 2024-07-08 21:25:18
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 5,627 bytes
コンパイル時間 6,180 ms
コンパイル使用メモリ 326,288 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-08 22:28:20
合計ジャッジ時間 6,033 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <tuple>
#include <map>
#include<set>
#include<queue>
#include<stack>
#include <unordered_set>
#include<thread>
#include<bits/stdc++.h>
#include <atcoder/all>
#include <cstdio>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//if(a < 0 || h <= a || b < 0 || w <= b)return;
// string abc = "abcdefghijklmnopqrstuvwxyz";
// string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using mint = modint998244353;
//using mint = modint1000000007;
template<typename T> using pq = priority_queue<T>;//?()
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;//?()
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector<vector<T>>>;
template<typename T> using vector4 = vector<vector<vector<vector<T>>>>;
template<typename T> using vector5 = vector<vector<vector<vector<vector<T>>>>>;
template<typename T> using vector6 = vector<vector<vector<vector<vector<vector<T>>>>>>;
template<typename T> using pairs = pair<T,T>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define rep1(i,n) for(int i = 1;i <= int(n);i++)
#define repm(i, m, n) for (int i = (m); (i) < int(n);(i)++)
#define repmr(i, m, n) for (int i = (m) - 1; (i) >= int(n);(i)--)
#define rep0(i,n) for(int i = n - 1;i >= 0;i--)
#define rep01(i,n) for(int i = n;i >= 1;i--)
//
ll GCD(ll a,ll b){
if(b == 0)return a;
return GCD(b, a % b);
}
//(ax + by = GCD(a,b))x,y
pair<long long, long long> extgcd(long long a, long long b) {
if (b == 0) return make_pair(1, 0);
long long x, y;
tie(y, x) = extgcd(b, a % b);
y -= a / b * x;
return make_pair(x, y);
}
struct UnionFind {
vector<int> par; // par[i]:i () par[3] = 2 : 32
vector<int> nu;
UnionFind(int N) : par(N) , nu(N){ //
for(int i = 0; i < N; i++) par[i] = i;
for(int i = 0;i < N;i++)nu[i] = 1;
}
int root(int x) { // xroot(x) = {x}
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) { // xy
int rx = root(x); //xrx
int ry = root(y); //yry
if (rx == ry) return; //xy(=)
nu[rx] += nu[ry];
nu[ry] = nu[rx];
par[rx] = ry; //xy(=)xrxyry
}
bool same(int x, int y) { // 2x, ytrue
int rx = root(x);
int ry = root(y);
return rx == ry;
}
int num(int x){//x
return nu[x];
}
};
ll n;
//
vector<ll> Ccomp(vector<ll> a){
vector<ll> b = a;
sort(b.begin(),b.end());
b.erase(unique(b.begin(),b.end()),b.end());//
vector<ll> rtn;
rep(j,a.size()){
ll pb = lower_bound(b.begin(),b.end(),a[j]) - b.begin();
rtn.push_back(pb);
}
return rtn;
}
/// ////////////////////////////////////////////
using F = ll;
using S = ll;
string s;
ll modPow(ll a, ll n, ll mod) { if(mod==1) return 0;ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1;
    } return ret; }
void cincout(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout<< fixed << setprecision(15);
}
//seg,seg-----
S op(S a,S b){return max(a,b);}//()
S e(){return 0;}//()
S mapping (F a,S b){return a + b;}//
F composition (F a,F b){return a + b;}//
F id(){return 0;}//
vector<int> Op(vector<int> a,vector<int> b){a.insert(a.end(),b.begin(),b.end()); return a;}
vector<int> E(){return vector<int> (0);}
ll INF = ll(2e9);
map<vector<int>,int> maps;
int main() {
cincout();
ll h,w;
cin >> h >> w;
vector2<int> a(h,vector<int>(w));
vector2<int> b(h,vector<int>(w));
vector2<int> c(h,vector<int>(w));
//vector2<int> b(h,vector<int>(w));
rep(j,h){
string s;
cin >> s;
rep(i,w){
if(s.substr(i,1) == "#")a[j][i] = 1;
else a[j][i] = 0;
}
}
rep(j,h){
cin >> s;
rep(i,w){
if(s.substr(i,1) == "#")b[j][i] = 0;
else b[j][i] = 1;
}
}
rep(j,h){
rep(i,w){
c[j][i] = a[h-j-1][w - i - 1];
}
}
bool st = a == b,sc = c == b;
double ans = 0;
double now = 1;
double noww = 1;
if(!st && !sc){
cout << -1 << endl;
return 0;
}
rep(j,1e5){
//cout << ans << " " << now << endl;
if(j % 2 == 0){
if(st){
ans += (j + 1) * noww * (1 - now);
noww *= now;
}
}
else{
if(sc){
ans += (j + 1) * noww * (1 - now);
noww *= now;
}
}
now /= 2;
}
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0